Page 1 of 1
js function not getting called OnChange of listbox selection
Posted: Fri Aug 27, 2004 12:58 pm
by voltrader
For some reason, this function is not getting called OnChange of the listbox selection; i put an alert in the function earlier to make sure.
Code: Select all
function refresh_page(search)
{
search.action="search.php&do=refresh";
search.method="post";
search.submit();
}
My select statement is as follows:
Code: Select all
<select name=registї] size=3 multiple onChange="refresh_page(document.search);">
Any ideas on why?
Posted: Fri Aug 27, 2004 1:04 pm
by feyd
Code: Select all
<html>
<script language="Javascript">
function refresh_page(search)
{
alert('hi');
// search.action="search.php&do=refresh";
// search.method="post";
// search.submit();
}
</script>
<body>
<form name="selection">
</form>
<select name=registї] size=3 multiple onChange="refresh_page(document.search);">
<option>opt1</option>
<option>opt2</option>
<option>opt3</option>
</select>
</body>
</html>
sure works for me.
Posted: Fri Aug 27, 2004 1:29 pm
by voltrader
You're right feyd, the alert does work... I must've done something wrong before.
The submit in the form doesn't seem to work, however - do you see anything obviously wrong with the code?
Posted: Fri Aug 27, 2004 1:32 pm
by feyd
well... if you have an element called "submit" it have an error..
Posted: Fri Aug 27, 2004 3:04 pm
by voltrader
I still haven't gotten to the bottom of it, so I tried to give an alert of value of regist[], and changed the function to:
Code: Select all
<html>
<script language="Javascript">
function refresh_page(search)
{
for (i=0, i<search.registї].length; i++)
{
alert(search.registїi].value);
}
// search.action="search.php&do=refresh";
// search.method="post";
// search.submit();
}
Is it possible to switch on run-time error messages in IE for javascript? It would make it much easier to debug!
Posted: Fri Aug 27, 2004 3:08 pm
by feyd
Tools > Internet Options > Advanced (tab)
uncheck "disable script debugging", and check "display a notification about every script error"
Posted: Fri Aug 27, 2004 3:14 pm
by voltrader
Hah! thanks!
Posted: Fri Aug 27, 2004 3:30 pm
by voltrader
The error I get is:
search.submit() is not a function.
i also tried the long-hand to no avail: document.search.submit();
Posted: Fri Aug 27, 2004 3:33 pm
by feyd
did you name one of your form's elements "submit" ?
Posted: Fri Aug 27, 2004 3:36 pm
by voltrader
No element names are "submit", but a button type="submit". Could that be it?
Posted: Fri Aug 27, 2004 3:40 pm
by feyd
post the form please.
Posted: Fri Aug 27, 2004 3:49 pm
by voltrader
Code: Select all
<script language="JavaScript">
function refresh_page(srch)
{
document.search.action="search.php&act=do";
document.search.method="post";
document.search.submit();
}
</script>
<form name=search enctype="multipart/form-data" action='results.php' method=post>
<input type=hidden name=reg value=>
<table width="85%" align=center border=0 cellpadding=0 cellspacing=0>
<tr align=center width="100%">
<td id="bigtext" colspan=2>Search</td>
</tr>
<tr class=normalbg>
<td class=normaltxt width="50%" valign="top">
<table align=center width="100%" cellpadding=6 cellspacing=0 border=0>
<tr>
<td id="lefthead" colspan=2> information</td>
</tr>
<tr>
<td valign=top class=normaltxt nowrap><br>Choose:</td>
<td valign=top class=normaltxt>
<br>
<select style="width:200" name=reglistї] size=7 multiple>
<option value="1" wrap>selection 1</option>
</select>
</td>
</tr>
<tr>
<td colspan=2 align=left class=normaltext>
</td>
</tr>
<tr>
<td valign=top class=normaltext nowrap>
Choose registries:
</td>
<td>
<select name=registї] size=3 multiple onChange="javascript: refresh_page(document.search);">
<option value="register 1" selected >Register 2</option>
<option value="register 2" selected >Register 1</option>
<option value="Other" selected >Other</option>
</select>
</td>
</tr>
<tr>
<td colspan=2 align=center class=normaltext>
</td>
</tr>
<tr>
</tr>
</table>
<td width=50% valign=top>
<table width="100%" cellpadding=6 cellspacing=0 border=0>
<tr>
<td id="lefthead" colspan=2> Location </td>
</tr>
<tr>
<td class=normaltxt nowrap>Zipcode:</td>
<td class=normaltxt nowrap> <input type=text name=zipcode size=6 value="">
within
<select name=distance>
<option value="">any</option>
<option value="5" >5</option>
<option value="10" >10</option>
<option value="15" >15</option>
<option value="20" >20</option>
<option value="30" >30</option>
<option value="50" >50</option>
<option value="75" >75</option>
<option value="100" >100</option>
</select> <select name=metric>
<option>N/A</option>
<option value="miles" selected >miles</option>
<option value="km" >km</option>
</select> </td>
</tr>
<tr>
<td class=normaltxt>Country:</td>
<td> <select name=country>
<option value="1" >United States Of America</option>
</select> </td>
</tr>
<tr>
<td colspan=2> </td>
</tr>
<tr>
<td id="lefthead" colspan=2> Price range </td>
</tr>
<tr>
<td class=normaltxt colspan=2> </td>
</tr>
<tr>
<td class=normaltxt colspan=2 nowrap> Minimum price:
<input type=text name=price_min size=5> Maximum price:
<input type=text name=price_max size=5> </td>
</tr>
<tr>
<td colspan=2> </td>
</tr>
<tr>
<td id="theadl" colspan=2> Other </td>
</tr>
<tr align=center>
<td class=code colspan=2> <table width="100%" align=center border="0">
<tr>
<td class=normaltxt width=130>Photos only: </td>
<td class=normaltxt align=left> <input type=checkbox name=photos_only value=1>
</td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<center class=code>
<input type=button name=s value="back" onclick="javascript:history.back();">
<input type=submit name=start value="start search">
</center>
Apologies for the messy code :p