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 = "#ffffff">
<cfinclude template="../../Connections/Connection2.cfm">
<CFQUERY DATASOURCE = #MM_Connection2_DSN# username=#MM_Connection2_USERNAME# password=#MM_Connection2_PASSWORD# NAME = "GetStates">
SELECT StateCode, State
FROM States
ORDER BY State
</CFQUERY>
<SCRIPT LANGUAGE = "JavaScript">
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("No match."
;
}
}
</SCRIPT>
<FORM>
<TABLE BORDER = "0">
<TR>
<TD>
<SELECT NAME = "Start">
<OPTION VALUE = "0">Select State
<CFOUTPUT QUERY = "GetStates">
<OPTION VALUE = "#StateCode#">#StateCode#
</CFOUTPUT>
</SELECT>
</TD>
<TD><INPUT TYPE = "button" VALUE = "View" onClick = "JumpTo(this.form)"></TD>
</TR>
<TR>
<TD COLSPAN = "2">
<SELECT NAME = "StateCode">** This should be empty till a person selects from the "Start" field above.**
<OPTION VALUE = "0">Select State
<CFOUTPUT QUERY = "GetStates">
<OPTION VALUE = "#State#">#State#
</CFOUTPUT>
</SELECT>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
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 = "#ffffff">
<cfinclude template="../../Connections/Connection2.cfm">
<CFQUERY DATASOURCE = #MM_Connection2_DSN# username=#MM_Connection2_USERNAME# password=#MM_Connection2_PASSWORD# NAME = "GetStates">
SELECT StateCode, State
FROM States
ORDER BY State
</CFQUERY>
<SCRIPT LANGUAGE = "JavaScript">
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("No match."
}
}
</SCRIPT>
<FORM>
<TABLE BORDER = "0">
<TR>
<TD>
<SELECT NAME = "Start">
<OPTION VALUE = "0">Select State
<CFOUTPUT QUERY = "GetStates">
<OPTION VALUE = "#StateCode#">#StateCode#
</CFOUTPUT>
</SELECT>
</TD>
<TD><INPUT TYPE = "button" VALUE = "View" onClick = "JumpTo(this.form)"></TD>
</TR>
<TR>
<TD COLSPAN = "2">
<SELECT NAME = "StateCode">** This should be empty till a person selects from the "Start" field above.**
<OPTION VALUE = "0">Select State
<CFOUTPUT QUERY = "GetStates">
<OPTION VALUE = "#State#">#State#
</CFOUTPUT>
</SELECT>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>