dropdownlist

create dropdownlist with js, jq

by simpleorchid

HTML

<div id="droptest">
</div>

<select id='something123'  onchange='test(target);'>
<option value="Audi">Audi</option>
  <option value="BMW">BMW</option>
  <option value="Mercedes">Mercedes</option>
  </select>

JavaScript

function test(target){
	alert("hello");
	alert(target);
}

var arrDesc = ["Main Tel", "Main", "Tel", "Cell", "Mobile", "Res", "Toll Free", "Direct Line", "Direct", "Voice Mail", "Fax", "Ext", "Vanc. Line"];

var htmlTags = "<select id='something'  onchange=\"test(target);\">"
		for(var i = 0; i < arrDesc.length; i++){
    htmlTags = htmlTags.concat("<option value='"+ i + "'>");
    htmlTags = htmlTags.concat(arrDesc[i]);
    htmlTags = htmlTags.concat("</option>");
							}
    htmlTags = htmlTags.concat("</select>");


$(document).ready(function(){
	$("#droptest").before(htmlTags);
});