Click to See Complete Forum and Search --> : onclick CheckBox and radio button! HELP URGENT


lting
09-22-2004, 12:59 AM
function radio(){
if(document.form.checkPayroll.checked == true){
document.form.radioPayroll.value == 1;
}
}

<input name="checkPayroll" type="checkbox" id="checkPayroll" value="1" onClick="radio();">


READ = <input name="radioPayroll" type="radio" value="1">
WRITE = <input name="radioPayroll" type="radio" value="2">

is this correct?

i want to do a function when ever i tick at the check box - checkPayroll, the radio button - radioPayroll for 'read' will be automatically checked as well ...

document.form.radioPayroll.checked == true?

javaNoobie
09-22-2004, 01:38 AM
having multiple radio buttons in the same group will require to reference them by arrays. Probably like document.forms[0].elements['radioPayroll'][0].checked = true

Charles
09-22-2004, 06:05 AM
By definition, you can only have one option of a radio button set selected at a time. Use check boxes for this.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<meta name="Content-Style-Type" content="text/css">
<title>Example</title>

<style type="text/css">
<!--
form {width:10em}
fieldset {padding:1ex}
label {display:block; margin:1em 0}
button {display:block; margin:auto}
-->
</style>

</head>
<body>
<form action="someScript.pl">
<fieldset>
<legend>Example</legend>

<label><input type="checkbox" name="read" onclick="this.form.write.checked = this.checked"> Read</label>

<label><input type="checkbox" name="write" onclick="this.form.read.checked = this.checked"> Write</label>

<button type="submit">Submit</button>
</fieldset>
</form>
</body>
</html>