Javascript Reference
Categories: SELECT

javascript SELECT add( )

@March 15, 2008, 1:22 a.m.
add( )Firefox/Netscape/NN 6 IE 5 Chrome/Safari/DOM 1  

add(newOptionElement[, positionIndex]) add(newOptionElement, optionElementReference)

  

Adds a new option element to the current select element. Unfortunately, IE and Netscape 6 don't agree on the parameter values for this method. While all browsers require a reference to a newly created option element (the value returned from a document.createElement("option") method is appropriate for that), the second parameter varies with browser. In IE, the second parameter is optional and supplies a numeric index to the existing option element; the new option is inserted in front of that element. With no second parameter, the new option is appended to the existing option elements. In Netscape 6 (which implements the W3C DOM recommendation from the unfinished HTML module), the second parameter is required. The parameter is either a reference to an existing option element (the new option is inserted before that referenced option) or null (the new option is appended to the existing options).

 
Parameters
 
  • Reference to an option element created by script, usually with the document.createElement( ) method.
  • Optional IE integer parameter signifying the existing nested option element in front of which the new option is to be inserted. Omitting this parameter causes the new option to be appended to the end of the options list.
  • Reference to an option element in front of which the new option is to be inserted. You may also use null to append the new option to the end of the option list.
 
Returned Value

None.

hello
soypeestiff - 2013-12-23
Under moderation.
soypeestiff - 2013-12-06
Under moderation.
soypeestiff - 2013-12-04

Powered by Linode.