Forum Moderators: open

Message Too Old, No Replies

getElementById firefox issue

         

FiRe

2:59 pm on Sep 28, 2006 (gmt 0)

10+ Year Member



I have this function:

function dl(id) {
var pass = document.getElementById("pass" + id).value;
if (pass == "") {
alert("Please enter a password!");
}
else {
window.location.href = "download.php?id=" + id + "&pass=" + pass;
}
}

This is the HTML:

<TD WIDTH=135 HEIGHT=15><input type="password" class="pword" name="pass2"></TD>
</TR>
<TR>
<TD ROWSPAN=2>
<a href="#" onclick="dl(2);"><IMG SRC="images/submit.png" WIDTH=69 HEIGHT=27 ALT="" border="0"></a></TD>
</TR>

It should be picking up "pass2" when they click on submit but firefox gives the error:

Error: document.getElementById("pass" + id) has no properties

This works in IE however... Any ideas?

Little_G

3:14 pm on Sep 28, 2006 (gmt 0)

10+ Year Member



Hi,

You need to add an 'id' attribute to your input element:

<input type="password" class="pword" name="pass2" id="pass2">

Andrew

FiRe

3:27 pm on Sep 28, 2006 (gmt 0)

10+ Year Member



of course im such an idiot how could i forget * rolls eyes *
thanks for reminding me :-)