Click to See Complete Forum and Search --> : drop-down menu stuff


fuxmyl
02-13-2003, 03:34 PM
I have a form in Frontpage that has a drop down menu with
a list of part numbers. the name of the dropdown menu
is "partnumber1". Next to it I have a blank text box and
the name of that is "description1". I would like it if
when a partnumber from the drop-down menu was selected it
would populate the text box or "description1" with the
proper description. I have an access data base with part
numbers and descriptions, 2 columns named partnumber and
description. What would be the best and easiest way to do
this?

Thanks

AdamBrill
02-13-2003, 09:46 PM
Well, first of all you would have to get the database info into javascript. Lets say that after you do that, all of the database information is in two arrays, partnumber and description. Then, the code would look something like this:


<script language=javascript>
function Update(element,formname)
{
x=0;
ran=false;
do
{
if(partnumber[x]==element.value)
{
ran=true;
break;
}
x++;
} while(partnumber[x])
if(ran)
{
formname.results.value=description[x];
}
}
document.write("<form>");
document.write("<select onclick='Update(this,this.form);'>");
document.write("<option value='SELECT'>Please select</option>");
x=0;
do
{
document.write("<option value='"+partnumber[x]+"'>"+partnumber[x]+"</option>");
x++;
} while(partnumber[x])
document.write("</select>");
document.write("<input type=text name='results'>");
document.write("</form>");
</script>


I would suggest that you put something in a <noscript> tag, just in case someone comes to your site that doesn't have javascript enabled...