Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
October 21, 2014, 10:29:57 AM

Pages: [1]   Go Down
  Print  
Author Topic: How to pass values into a newly opened window  (Read 3164 times)
ypsio0
Trekkie
**
Offline Offline

Posts: 11


« on: August 28, 2008, 06:29:52 PM »

Say a user clicks on a link to open a new window (window.open())that has a checkbox form.

I would like the form's default checkboxes to correspond to the link that the user clicked on to get to the form.

How would I do that?
Logged
tcstiger
Trekkie
**
Offline Offline

Posts: 10


« Reply #1 on: August 29, 2008, 12:05:45 AM »

Code:
<html >
<head>
<title>Untitled Document</title>
<script>
function createWindow()
{
  secondwindow = window.open('','example','height=300,width=200,scrollbars=yes'); 
  if (secondwindow != null)
    {
       var windowHTML= "<html><head><title>Second Window</title></head>";
       windowHTML += "<body><h1 align='center'>";
       windowHTML += "Another window!</h1><hr><div align='center'><form action='#' method='get'>";
       windowHTML += "<input type='button' value='Set main red' onclick='window.opener.document.bgColor=\"red\";' />";
       windowHTML += "<br ><input type='button' value='CLOSE' onclick='self.close();' />";
       windowHTML += "</form></div></body></html>";

      secondwindow.document.write(windowHTML);
       secondwindow.focus();
    }
}
</script>

</head>
<body>
<form action="#" method="get">
<input type="button" value="new window" onclick="createWindow();" />
<input type="button" value="set red" onclick="if (window.secondwindow) {secondwindow.document.bgColor='red';secondwindow.focus();}" />
</form>
</body>
</html>
Logged

MCSD - MCSE+i
Pages: [1]   Go Up
  Print  
 
Jump to: