Question : Move div if specific checkbox is checked/unchecked

I have a div called 'bpaPreviouslyLicensedX'. I have a checkbox with an id of 'bpaPreviouslyLicensedDiv'.

If the checkbox called 'bpaPreviouslyLicensed' is checked, then the div should have a 'left' position of '15px'. If the checkbox is unchecked, the div should change to have a 'left' of '25px'.

Answer : Move div if specific checkbox is checked/unchecked

remixed :

(right id)
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
.pos15 { position: absolute; top: 80 px; left: 15px;background:#888; color:#F33}
.pos25 { position: absolute; top: 80 px; left: 25px;background:#888; color:#00F}
</style>
<script language="javascript">
	function changeStyle(o) {
		if(o.checked) {
			document.getElementById(o.getAttribute("value")).setAttribute('class','pos25');
		}
		else {
			document.getElementById(o.getAttribute("value")).setAttribute('class','pos15')
		}
	}
</script>
</head>
<body>
<input id="bpaPreviouslyLicensedDiv" type="checkbox" onclick="changeStyle(this);" value="bpaPreviouslyLicensedX" />&nbsp;bpaPreviouslyLicensedDiv<br />
<br />
<div id="bpaPreviouslyLicensedX" class="pos15">I'm in div bpaPreviouslyLicensedX</div><br />
</body>
</html>
Random Solutions  
 
programming4us programming4us