Forum Moderators: open

Message Too Old, No Replies

Check box

         

JuicyScript

9:19 am on Feb 18, 2010 (gmt 0)

10+ Year Member



Hi,

I wonder if anyone can help me on this.

A Checkbox, which validates if the check box is checked or unchecked. but if the checkbox is checked it will pop-up a new window page.
This it what i have.

anyone can help me here?


<input type = "checkbox" name = "chk1" onclick = "newPage('http://www.example.com')">

<script type = "text/javascript">
var count = 0;
function newPage(page) {
if (count == 0) { // once only
count ++;
OpenWin = this.open(page,"CtrlWindow","top=80,left=100,screenX=100,screenY=80,width=550,height=460,toolbar=no,menubar=no,location=no, scrollbars=no,resizable=yes");
}

function closepop() {if (OpenWin != null) OpenWin.close() }
window.onunload = closepop;
}
</script>

[edited by: Fotiman at 1:46 pm (utc) on Feb 18, 2010]
[edit reason] Examplified URL [/edit]

Fotiman

1:49 pm on Feb 18, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Does this work for you?
onclick = "if(this.checked){newPage('http://www.example.com');}"

rocknbil

6:02 pm on Feb 18, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!-- doctype on one line -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Untitled</title>
<script type = "text/javascript">
window.onload=function() {
if (document.getElementById('chk1')) {
document.getElementById('chk1').onclick=function() { newPage(this); };
}
};
function newPage(chkObj) {
if (chkObj.checked) {
var day = new Date();
var id = day.getTime();
var params = 'top=80,left=100,screenX=100,screenY=80,width=550,height=460,scrollbars,resizable';
var win = open(chkObj.value,id,params);
}
}
</script>
</head>
<body>
<form action="">
<input type="checkbox" name="chk1" id="chk1" value="http://www.example.com">
</form>
</body>
</html>