this doesn’t seem to work, and resets checked…would like to only update if checked
<iframe id="time" name="time" type="text/html" src="http://time.is/"></iframe>
<form id="url" onsubmit="" method="post">
<input type="text" name="target" id="target" value="http://time.is" size="40"></form>
<input type="checkbox" name="check1" />
$('.url').submit {
if($('input[name="check1"]', this).is(':checked')) {
document.getElementById(time).src = url;
} else {
alert('no');
}
return false;
});
There are multiple errors:
1.you need to add submit button inside html form (or have a way to trigger form submission with JavaScript), something like this:
2.the varible
urlis undefined, you may add the following line in the JavaScript3.
should be
4.change the first line of script from
to
5.as Trinh Hoang Nhu said, check box should be inside form because you are using
Here’s the updated test