In my HTML page that calls Ajax I have a field defined as:-
<td width=195 style="position:absolute; visibility: hidden;" id="CNumber" name="CNumber"></td>
and in Ajax I attempt to retrieve its contents by :-
var KaartNommer = document.getElementById("CNumber").innerHTML;
and I have also tried:-
var KaartNommer = document.getElementById("CNumber").value;
both fail and doing an alert() I get told that it is undefined.
Please tell me how I got this wrong as other field values on the same webpage defined & retrieved in the same manner work fine.
Regards,
Alf Stockton.
![]() |
0 |
![]() |
Are you sure the td with Cnumber ID is the only instance, any chance that the td is repeated?
Long Live .NET
Kazi Manzur Rashid (Amit)
_________________________
Web: http //dotnetshoutout.com
Blog: http://weblogs.asp.net/rashid
Twitter: http://twitter.com/manzurrashid
![]() |
0 |
![]() |
Does not look likely as the surrounding and offending code looks like:-
<tr>
<td width=195 style="position:absolute; visibility: hidden;" id="NumberOfCard" name="NumberOfCard"></td>
<td width=195 style="position:absolute; visibility: hidden;" id="SlotsIssued"></td>
<td width=195 style="position:absolute; visibility: hidden;" id="TablesIssued"></td>
Note that I have changed the name from CNumber to NumberOfCard, just in case that was the problem.
Regards,
Alf Stockton.
![]() |
0 |
![]() |
Hi,
It sound wacky, document.getElementById("CNumber").innerHTML should work!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Page</title><script language="javascript" type="text/javascript">
// <!CDATA[function Button1_onclick() {
var KaartNommer = document.getElementById("NumberOfCard").innerHTML;
alert(KaartNommer);
}// ]]>
</script></head>
<body>
<table>
<tr>
<td width="195" style="position: absolute; visibility: hidden;" id="NumberOfCard"
name="NumberOfCard">
alert string
</td>
<td width="195" style="position: absolute; visibility: hidden;" id="SlotsIssued">
</td>
<td width="195" style="position: absolute; visibility: hidden;" id="TablesIssued">
</td>
</tr>
</table>
<input id="Button1" type="button" value="button" onclick="return Button1_onclick()" />
</body>
</html>If the above code work,your code should work too,please check out if it works on your machine.
If it works on your machine,it must be some mistakes in your code,you can post your code to us.
Best Regards
Sincerely,
Jin-Yu Yin
Microsoft Online Community Support
![]() |
0 |
![]() |
Hi,
It sound wacky, document.getElementById("CNumber").innerHTML should work!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Page</title><script language="javascript" type="text/javascript">
// <!CDATA[function Button1_onclick() {
var KaartNommer = document.getElementById("NumberOfCard").innerHTML;
alert(KaartNommer);
}// ]]>
</script></head>
<body>
<table>
<tr>
<td width="195" style="position: absolute; visibility: hidden;" id="NumberOfCard"
name="NumberOfCard">
alert string
</td>
<td width="195" style="position: absolute; visibility: hidden;" id="SlotsIssued">
</td>
<td width="195" style="position: absolute; visibility: hidden;" id="TablesIssued">
</td>
</tr>
</table>
<input id="Button1" type="button" value="button" onclick="return Button1_onclick()" />
</body>
</html>If the above code work,your code should work too,please check out if it works on your machine.
If it works on your machine,it must be some mistakes in your code,you can post your code to us.
Best Regards
Sincerely,
Jin-Yu Yin
Microsoft Online Community Support
![]() |
0 |
![]() |
Due to pressure of deadlines I have stopped with the Ajax/Javascript & have used php session variables which work fine and have resolved the problem.
Thanks for trying to help.
Regards,
Alf Stockton.
![]() |
0 |
![]() |