Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic list menu

Status
Not open for further replies.

superfly404

Technical User
Feb 1, 2005
24
US
Is there a way to create a dynamic list menu in a form with Javascript...

<form name="form1" method="post" action="">
From<select name="select">
</select>
</form>

Using code from an XML file like this stored in a different file?

<FROM="John"></FROM>
<FROM="Mary"></FROM>
<FROM="Thomas"></FROM>
 
var oOption = parent.document.createElement("OPTION");
oOption.id = newname;
oOption.text = newname;
oOption.value = newname;
oSelect.add(oOption,oSelect.options.length-1);
oOption.selected = "selected";


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Don't know much about the XML part, but you can add options to a select list like this:
Code:
var oSelect = parent.document.getElementById('[i]listname[/i]');
var oOption = parent.document.createElement("OPTION");
oOption.id = "[i]newid[/i]";
oOption.text = "[i]newtext[/i]";
oOption.value = "[i]newvalue[/i]";
oSelect.add(oOption,oSelect.options.length-1);
oOption.selected = "selected";


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top