<script language=javascript>
<!--
//--------------------------------------------------------------------------
function f_test1()
{
alert(frm_main.elements[3].name);
alert(frm_main.elements[3].value);
}
function f_test2()
{
alert(frm_main.elements[4].name);
alert(frm_main.elements[4].value);
}
function f_test3()
{
alert(frm_main.elements[5].name);
alert(frm_main.elements[5].value);
}
// -->
</script>
Object names and values
This example depicts how to get object names and values dynamically within Javascript.
When the first checkbox is clicked, it gives the name and value of the first
label within the form. Note that the first field is element #3.
<form name=frm_main>
<center>
<input name=cbx_1 type=checkbox value="1" checked=false onclick="f_test1()">
<input name=cbx_2 type=checkbox value="1" checked=false onclick="f_test2()">
<input name=cbx_3 type=checkbox value="1" checked=false onclick="f_test3()">
<hr>
<input name=fld_atest value=Orange>
<input name=fld_xtest value=Apple>
<input name=fld_ztest value=Lemon>
Object names and values
This example depicts how to get object names and values dynamically within Javascript.
When the first checkbox is clicked, it gives the name and value of the first
label within the form. Note that the first field is element #3.
|
|