View Single Post
Old 03-28-2005, 11:41 AM   #6 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
first off, check boxes allow for multiple selections. are you sure you want to be using multiple checkboxes here? if so, then your programming logic is going to have to support checking if each one is selected, so it would make sense to give all your checkboxes different names, and a value of 0 or 1.

i re-created the examples to demonstrate the use of check boxes and radio buttons. keep in mind that this ONLY works on IE. =/ .. i haven't spent enough time with javascript to figure out how to make this work across non IE browsers.

parent.html
HTML Code:
<html>
<head>
<title>Parent</title>
<script language="JavaScript">
<!--
var win = null;

function pop(width,height,resize) {
  win = window.open('child.html', 'childwin', 'width='+width+',height='+height+',toolbar=0,scrollbars='+resize+',resizable='+resize+',location=0,statusbar=0,menubar=0');
  win.focus();
  return false;
}
-->
</script>
</head>
<body>
<form name="f" method="post" action="child.html" onsubmit="return send();">
Checkbox 1 value: <input type="text" name="checkbox1"><br>
Checkbox 2 value: <input type="text" name="checkbox2"><br>
Radio value: <input type="text" name="radio_option"><br>
Text Field value: <input type="text" name="parentfield"><br>
<a href=# onclick="return pop(640,480,'no');">Open Child</a>
</form>

</body>
</html>
child.html
HTML Code:
<html>
<head>
<title>Child</title>
<script language="JavaScript">
<!--
function send(form){
  // set text field
  window.opener.f.parentfield.value=form.childfield.value;
  // set check box 1
  window.opener.f.checkbox1.value=form.checkbox1.value;
  // set check box 2
  window.opener.f.checkbox2.value = form.checkbox2.value;
  
  // loop through radio group to see which one is checked
  for (x = 0; x < form.radio_option.length; x++){
    if(form.radio_option[x].checked == true)
      // set radio option from the selected button
      window.opener.f.radio_option.value = form.radio_option[x].value;
  } 

  window.close();
  return true;
}
-->
</script>
</head>
<body>
<form name="f" method="post" action="#"  onsubmit="send(this);">

<b>Check Boxes</b><br>
<input type="checkbox" name="checkbox1" value="1">Option 1<br>
<input type="checkbox" name="checkbox2" value="1">Option 2<br><br>

<b>Radio Boxes</b><br>
<input type="radio" name="radio_option" value="this is the first option">Option 1<br>
<input type="radio" name="radio_option" value="this is the second option">Option 2<br><br>

<b>Text Field</b><br>
<input type="text" name="childfield"> <input type="submit" name="submit" value="Send and Close">
</form>

</body>
</html>
hope that helps.
__________________
Mike
sde is online now   Reply With Quote