Hi folx,
I'm having trouble with radiobuttons and click event on JavaScript.
Check this piece of code:
==============================
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function Update_Info() {
var i;
var Cadena;
alert('Number of radiobuttons=' + document.academicos.raRegistro2.length);
renglon = -999999;
for (i=0;i<document.academicos.raRegistro2.length;i++){
if (document.academicos.raRegistro2.checked) {
renglon = i;
Cadena = document.academicos.raRegistro2.Sarta;
}
}
alert('Radiobutton Checked is in line ' + renglon);
}
</SCRIPT>
</HEAD>
<FORM NAME="academicos" ACTION = "./nom_mostrar_info.php?IndTabla=3" METHOD="POST">
<TABLE ID='TABLA_ESTUDIOS' BORDER='1'>
<TBODY>
<TR>
<TD><INPUT TYPE = 'RADIO' NAME = 'raRegistro2' ID='CELDA17' SARTA='A|B|C|D' onClick='javascript:Update_Info()'></TD>
</TR>
</TBODY>
</TABLE>
</FORM>
</HTML>
==============================
I assume that
document.academicos.raRegistro2.length = 1
because there's one radiobutton in the page at the beginning.
*
When I click on the radiobutton, the function "Update_Info()" must verify what radiobutton I clicked.
The sentence
alert('Number of radiobuttons='+document.academicos.raRegistro2.length);
sends me the following message:
Number of radiobuttons=undefined
instead of
Number of radiobuttons=1
*
If "document.academicos.raRegistro2.length" is "undefined", logically the for... loop doesn't work, althought I did click the radiobutton.
*
But, if you add another radiobutton below the existent one,
(...)
<TR>
<TD><INPUT TYPE = 'RADIO' NAME = 'raRegistro2' ID='CELDA12' SARTA='C|D|E|F' onClick='javascript:Update_Info()'></TD>
</TR>
(...)
the code works beautiful (number of radiobuttons = 2, radiobutton checked is in line 1 or 2 , etc)
*
What am I doing wrong?
How must be initialized the length of raRegistro2?
Thanx in advance!
Caliban
I'm having trouble with radiobuttons and click event on JavaScript.
Check this piece of code:
==============================
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function Update_Info() {
var i;
var Cadena;
alert('Number of radiobuttons=' + document.academicos.raRegistro2.length);
renglon = -999999;
for (i=0;i<document.academicos.raRegistro2.length;i++){
if (document.academicos.raRegistro2.checked) {
renglon = i;
Cadena = document.academicos.raRegistro2.Sarta;
}
}
alert('Radiobutton Checked is in line ' + renglon);
}
</SCRIPT>
</HEAD>
<FORM NAME="academicos" ACTION = "./nom_mostrar_info.php?IndTabla=3" METHOD="POST">
<TABLE ID='TABLA_ESTUDIOS' BORDER='1'>
<TBODY>
<TR>
<TD><INPUT TYPE = 'RADIO' NAME = 'raRegistro2' ID='CELDA17' SARTA='A|B|C|D' onClick='javascript:Update_Info()'></TD>
</TR>
</TBODY>
</TABLE>
</FORM>
</HTML>
==============================
I assume that
document.academicos.raRegistro2.length = 1
because there's one radiobutton in the page at the beginning.
*
When I click on the radiobutton, the function "Update_Info()" must verify what radiobutton I clicked.
The sentence
alert('Number of radiobuttons='+document.academicos.raRegistro2.length);
sends me the following message:
Number of radiobuttons=undefined
instead of
Number of radiobuttons=1
*
If "document.academicos.raRegistro2.length" is "undefined", logically the for... loop doesn't work, althought I did click the radiobutton.
*
But, if you add another radiobutton below the existent one,
(...)
<TR>
<TD><INPUT TYPE = 'RADIO' NAME = 'raRegistro2' ID='CELDA12' SARTA='C|D|E|F' onClick='javascript:Update_Info()'></TD>
</TR>
(...)
the code works beautiful (number of radiobuttons = 2, radiobutton checked is in line 1 or 2 , etc)
*
What am I doing wrong?
How must be initialized the length of raRegistro2?
Thanx in advance!
Caliban