JavaScript and client side scripting.
Moderator: General Moderators
dstefani
Forum Contributor
Posts: 140 Joined: Sat Jan 11, 2003 9:34 am
Location: Meridian Idaho, USA
Post
by dstefani » Tue Mar 01, 2005 5:16 pm
Here is a snippet of source code which generates an error in the javascript console of Firefox:
Here is the error:
Code: Select all
Error: jump1.jumpbox has no properties
Here is the code:
Code: Select all
<div id="dataNav">
<form name="jump1">
<table id="data_nav_table" summary="Data Navigation" cellspacing="0" width="100%" border="0">
<tr>
<td>
<span class="navSummary">Go to page:</span>
<select name="jumpbox" OnChange="location.href=jump1.jumpbox.optionsїselectedIndex].value">
<option value="/~donzo/clca/www/admin/index.php?v=kb&p=4&page=1" title="Page 1">1</option>
<option value='' selected>2</option>
</select>
</td>
<td align="right"><input type="button" value="<<" onclick="document.location.href='/~donzo/clca/www/admin/index.php?v=kb&p=4&page=1'" />
<input type="button" value="<" onclick="document.location.href='/~donzo/clca/www/admin/index.php?v=kb&p=4&page=1'" /> <span class="navSummary">Records 4 to 6 of 6</span> </td></tr>
</table>
</form>
</div>
I must be looking right at the problem, but I can't see it!
thanks,
- dstefani
Last edited by
dstefani on Wed Mar 02, 2005 6:24 am, edited 1 time in total.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Mar 01, 2005 5:20 pm
Code: Select all
var obj = document.formsї'jump1'].elementsї'jumpbox'];
location.href = obj.optionsїobj.selectedIndex].value;
CoderGoblin
DevNet Resident
Posts: 1425 Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany
Post
by CoderGoblin » Wed Mar 02, 2005 3:10 am
Although Feyd's code is correct when dealing with javascript items in forms you can abbreviate it to:
Code: Select all
var obj = document.jump1.jumpbox;
location.href = objїobj.selectedIndex].value;
Make sure the form name and element names are unique.
dstefani
Forum Contributor
Posts: 140 Joined: Sat Jan 11, 2003 9:34 am
Location: Meridian Idaho, USA
Post
by dstefani » Wed Mar 02, 2005 6:21 am
Make sure the form name and element names are unique.
That was the problem, I knew this code works, I was using it in other places, but in the last few instances I was using it at the top and the bottom of the generate page of data.
Arrg!
Thanks!
- dstefani
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Mar 02, 2005 9:22 am
I tend to use the full length versions because the code I build is iterative in nature often. I'd require using eval() otherwise. Since some objects have names that will not work in short form, I always go for long form anyways.