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

Populating a combo with JS using values from a recordset..

Status
Not open for further replies.

ashvn

Programmer
Mar 21, 2001
33
MU
Hi, I'm still a newbie at using PHP, and I've been trying to populate a combo box with JavaScript using values from a recordset. Anybody knows how I can do that?

Thanks a lot for the help!
 
Hmm, thanks, and how can that be done more precisely? Any piece of code on the subject would be very welcome. Thanks again!
:)
 
ok, thanks, but i just had a look at the JS forum, and came out completely lost!! Could u please indicate me where the thread talking about what I want is? Thanks a lot!!
:)
 
i myself dont go much to javascript forums

buddy i am giving u an example

function AddText()
{
a=new Option("Option Value here","Text Here") //order may change
document.frm.drpdown.options[document.form.drpdown.length]=a
}

create a dropdown called drpdown and form name must be frm.
create a button like this:
<input type=button value=&quot;ADD&quot; onclick=&quot;AddText()&quot;>

this code is not mine.

the advantage of php is that in html the list is hardcoded, but using php u can add as many as u want.
 
thanks a lot, but what I actually wanted is the php code embedded into the JS function to create the different options.
 
create a string
<?php
$strn=&quot;value1//value2//value3&quot;;
$strn1=split($strn1,&quot;//&quot;) //i am not that good in php
?>

function AddText()
{
<?php
for($i=0;i<$strn1.length();i++)
{
?>
a=new Option(&quot;<%=$strn1[$i]%>&quot;,&quot;<%=$strn1[$i]%>&quot;) //order may change
document.frm.drpdown.options[document.form.drpdown.length]=a
<?php
}
?>
}

check this out.

 
Cool!!! That seems to be just what i wanted!
Thanks!!
:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top