W
w.bristow
Hi all,
I have found a script on the web which lets me click on an image and it
gives focus & fills in a certain radio button corresponding to id. It
works, however I want to know how it works, for reference.
IN HEADER
<script language="JavaScript" type="text/JavaScript">
function setCheckedValue(radioObj, newValue) {
if(!radioObj)
return;
var radioLength = radioObj.length;
if(radioLength == undefined) {
radioObj.checked = (radioObj.value == newValue.toString());
return;
}
for(var i = 0; i < radioLength; i++) {
radioObj.checked = false;
if(radioObj.value == newValue.toString()) {
radioObj.checked = true;
}
}
}
</script>
IN BODY
<td colspan="2" rowspan="2" valign="top" bgcolor="#CCFFCC"
class="boxhomiss"
onMouseOver="MM_swapImage('rentcard','','/Schemes/Images/rentcards/rentcaxton.gif',1)"
onMouseOut="MM_swapImgRestore()"><img src="/Schemes/Images/gho.gif"
alt="HEAD OFFICE" width="51" height="57"
onclick="setCheckedValue(document.forms['monopoly'].elements['Base'],
'Caxton');"></td>
<td rowspan="2" valign="middle" bgcolor="#CCFFCC"
class="boxhomissbut"
onMouseOver="MM_swapImage('rentcard','','/Schemes/Images/rentcards/rentcaxton.gif',1)"
onMouseOut="MM_swapImgRestore()">
<input type="radio" name="Base" id="Caxton"
value="Caxton"></td>
Hope some one can explain the script to me, I understand the onclick
part, as this is just calling the function with the element 'Base' (the
radio button group) and radio button 'Caxton'. I know this much as I
have managed to edit the script to work for me the bit I don't
understand all that much is The Header section bit.
I have found a script on the web which lets me click on an image and it
gives focus & fills in a certain radio button corresponding to id. It
works, however I want to know how it works, for reference.
IN HEADER
<script language="JavaScript" type="text/JavaScript">
function setCheckedValue(radioObj, newValue) {
if(!radioObj)
return;
var radioLength = radioObj.length;
if(radioLength == undefined) {
radioObj.checked = (radioObj.value == newValue.toString());
return;
}
for(var i = 0; i < radioLength; i++) {
radioObj.checked = false;
if(radioObj.value == newValue.toString()) {
radioObj.checked = true;
}
}
}
</script>
IN BODY
<td colspan="2" rowspan="2" valign="top" bgcolor="#CCFFCC"
class="boxhomiss"
onMouseOver="MM_swapImage('rentcard','','/Schemes/Images/rentcards/rentcaxton.gif',1)"
onMouseOut="MM_swapImgRestore()"><img src="/Schemes/Images/gho.gif"
alt="HEAD OFFICE" width="51" height="57"
onclick="setCheckedValue(document.forms['monopoly'].elements['Base'],
'Caxton');"></td>
<td rowspan="2" valign="middle" bgcolor="#CCFFCC"
class="boxhomissbut"
onMouseOver="MM_swapImage('rentcard','','/Schemes/Images/rentcards/rentcaxton.gif',1)"
onMouseOut="MM_swapImgRestore()">
<input type="radio" name="Base" id="Caxton"
value="Caxton"></td>
Hope some one can explain the script to me, I understand the onclick
part, as this is just calling the function with the element 'Base' (the
radio button group) and radio button 'Caxton'. I know this much as I
have managed to edit the script to work for me the bit I don't
understand all that much is The Header section bit.