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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AJAX: Filling a select box with response text: Problem! Help? 1

Status
Not open for further replies.

jpo245

Programmer
Jan 16, 2005
45
US
Hi there everyone, just started fiddling around with AJAX.
Am using ajaxtoolbox.
Two files:
testajax.php [contains a selectbox with ID: TESTCOMBO
<select id="testcombo" size="10">
<option value='nothinghereyet'>nothing here yet</option>
</select>

options.php [file that ajax "GETS"]
<option value ='1'> Hahaha1! </option>
<option value ='1'> Hahaha2! </option>
<option value ='1'> Hahaha3! </option>


I then used ajaxtols to GET options.php,
and fill the innerhtml of "testcombo" with the responsetext of 'options.php'.

The result is that i get a screwed up combobox.
All the 3 options appear as are a single option, and i can't even select it.

Why doesnt this work?
The only way i manage to get it to work, was to wrap the ENTIRE selectbox in a container div, and then fill the innerhtml of this div with a full selectbox code (not just the options as i did earlier).

Anyone can explain why this happens?

Thanks!
 
I don't think you can set the innerHTML of a select object in that way. You are encouraged to use the proper DOM methods I think. The alternative is, as you have done, to set the innerHTML of a block level object with the full select and it's child options.

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top