zen69
06-19-2005, 11:00 AM
Here's what I'm trying to accomplish.
A user types in a town name they want to search. If the match was found in the optlon value, it is shown in the drop down. Then, the user clicks on the "Go" button to jump to the link.
Because I have employed the auto-fill java script I have attached at the bottom, I cannot seem to add href in the option value.
Is there a way to include both the city name and the corresponding link in the option value?
Example: http://www3.sympatico.ca/kinoue/files/form.htm
TIA
<head>
<script language="JavaScript" type="text/JavaScript">
<!--
function autoComplete (field, select, property, forcematch) {
var found = false;
for (var i = 0; i < select.options.length; i++) {
if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0) {
found=true; break;
}
}
if (found) { select.selectedIndex = i; }
else { select.selectedIndex = -1; }
if (field.createTextRange) {
if (forcematch && !found) {
field.value=field.value.substring(0,field.value.length-1);
return;
}
var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
if (cursorKeys.indexOf(event.keyCode+";") == -1) {
var r1 = field.createTextRange();
var oldValue = r1.text;
var newValue = found ? select.options[i][property] : oldValue;
if (newValue != field.value) {
field.value = newValue;
var rNew = field.createTextRange();
rNew.moveStart('character', oldValue.length) ;
rNew.select();
}
}
}
}
//-->
</SCRIPT>
</head>
<body>
<FORM>
<INPUT TYPE="text" NAME="input1" VALUE="" ONKEYUP="autoComplete(this,this.form.options,'value',true)">
<SELECT NAME="options" onChange="this.form.input1.value=this.options[this.selectedIndex].value">
<option value="#" selected>Town / City</option>
<OPTION VALUE="Calgary">Calgary
<OPTION VALUE="Camrose">Camrose
</SELECT>
<INPUT TYPE=BUTTON VALUE="GO"
onClick = "loadPage(this.form.options)">
</FORM>
</body>
A user types in a town name they want to search. If the match was found in the optlon value, it is shown in the drop down. Then, the user clicks on the "Go" button to jump to the link.
Because I have employed the auto-fill java script I have attached at the bottom, I cannot seem to add href in the option value.
Is there a way to include both the city name and the corresponding link in the option value?
Example: http://www3.sympatico.ca/kinoue/files/form.htm
TIA
<head>
<script language="JavaScript" type="text/JavaScript">
<!--
function autoComplete (field, select, property, forcematch) {
var found = false;
for (var i = 0; i < select.options.length; i++) {
if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0) {
found=true; break;
}
}
if (found) { select.selectedIndex = i; }
else { select.selectedIndex = -1; }
if (field.createTextRange) {
if (forcematch && !found) {
field.value=field.value.substring(0,field.value.length-1);
return;
}
var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
if (cursorKeys.indexOf(event.keyCode+";") == -1) {
var r1 = field.createTextRange();
var oldValue = r1.text;
var newValue = found ? select.options[i][property] : oldValue;
if (newValue != field.value) {
field.value = newValue;
var rNew = field.createTextRange();
rNew.moveStart('character', oldValue.length) ;
rNew.select();
}
}
}
}
//-->
</SCRIPT>
</head>
<body>
<FORM>
<INPUT TYPE="text" NAME="input1" VALUE="" ONKEYUP="autoComplete(this,this.form.options,'value',true)">
<SELECT NAME="options" onChange="this.form.input1.value=this.options[this.selectedIndex].value">
<option value="#" selected>Town / City</option>
<OPTION VALUE="Calgary">Calgary
<OPTION VALUE="Camrose">Camrose
</SELECT>
<INPUT TYPE=BUTTON VALUE="GO"
onClick = "loadPage(this.form.options)">
</FORM>
</body>