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!

Dropdown box populating issue??

Status
Not open for further replies.

yogi564

Programmer
Oct 16, 2001
48
AU
Hi all,

This code below which is sort of giving me trouble. The problem is that currently both the dropdown box are populated to get it to work. But I only need the "Start" dropdown box to be populated, which I have already done. Only from the selection of "start", I need the "StateCode" to be populated, when a user selects on something from the "start" otherwise the "StateCode" should be empty at the begininning of the process. The "StateCode" field information is stored in the database, under the same table name called State. I have tried most of the javascript but nothing seems to click so far. Thank's

<BODY BGCOLOR = &quot;#ffffff&quot;>
<cfinclude template=&quot;../../Connections/Connection2.cfm&quot;>
<CFQUERY DATASOURCE = #MM_Connection2_DSN# username=#MM_Connection2_USERNAME# password=#MM_Connection2_PASSWORD# NAME = &quot;GetStates&quot;>
SELECT StateCode, State
FROM States
ORDER BY State
</CFQUERY>

<SCRIPT LANGUAGE = &quot;JavaScript&quot;>
function JumpTo(thisForm)
{var SelectItem = 0
var stringSub = thisForm.Start.value();
for (i=0; i< thisForm.StateCode.length; i++)
{var stringMain = thisForm.StateCode.text();
if (stringMain.indexOf(stringSub) == 0) {
SelectItem = i;
break;
}
}
if (SelectItem != 0) {
thisForm.StateCode.selectedIndex = SelectItem;
} else {
alert(&quot;No match.&quot;);
}
}
</SCRIPT>
<FORM>
<TABLE BORDER = &quot;0&quot;>
<TR>
<TD>
<SELECT NAME = &quot;Start&quot;>
<OPTION VALUE = &quot;0&quot;>Select State
<CFOUTPUT QUERY = &quot;GetStates&quot;>
<OPTION VALUE = &quot;#StateCode#&quot;>#StateCode#
</CFOUTPUT>
</SELECT>
</TD>
<TD><INPUT TYPE = &quot;button&quot; VALUE = &quot;View&quot; onClick = &quot;JumpTo(this.form)&quot;></TD>
</TR>
<TR>
<TD COLSPAN = &quot;2&quot;>
<SELECT NAME = &quot;StateCode&quot;>** This should be empty till a person selects from the &quot;Start&quot; field above.**
<OPTION VALUE = &quot;0&quot;>Select State
<CFOUTPUT QUERY = &quot;GetStates&quot;>
<OPTION VALUE = &quot;#State#&quot;>#State#
</CFOUTPUT>
</SELECT>
</TD>
</TR>
</TABLE>
</FORM>



</BODY>
</HTML>
 
Hi WWEBSPIDER,

I already tried this,the problem is that only works with one selection within that dropdown box. But when I go to select other state with the above URl using the populated tag statement below

<CFOUTPUT QUERY = &quot;GetStates&quot;>
<OPTION VALUE = &quot;#StateCode#&quot;>#StateCode#
</CFOUTPUT>

nothing happen to the second , third and so on selections. If you want why don't you try, and copy the above coding and try to use the above mention Url and then tell me if it works or not. Thank's.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top