Page 1 of 1

[SOLVED] JS: ERROR No Properties ?

Posted: Tue Mar 01, 2005 5:16 pm
by dstefani
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&#1111;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

Posted: Tue Mar 01, 2005 5:20 pm
by feyd

Code: Select all

var obj = document.forms&#1111;'jump1'].elements&#1111;'jumpbox'];
location.href = obj.options&#1111;obj.selectedIndex].value;

Posted: Wed Mar 02, 2005 3:10 am
by CoderGoblin
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&#1111;obj.selectedIndex].value;
Make sure the form name and element names are unique.

[SOLVED]

Posted: Wed Mar 02, 2005 6:21 am
by dstefani
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!

:roll:

Thanks!

- dstefani

Posted: Wed Mar 02, 2005 9:22 am
by feyd
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.