PDA

View Full Version : Script Help



comwwwdot
01-31-2010, 09:26 AM
Hi guys, could you help me on this script that I would like to implement.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Some Title
</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<form>
<fieldset>
<p><label for="txtCuryear">Academic Year</label><input type="text" name="txtCuryear" id="txtCuryear" /><input type="text" name="txtNxtyear" id="txtNxtyear" /></p>
</fieldset>
</form>
</body>
</html>

there I think I was able to solve it myself :D lol

<p><label for="txtCuryear">Academic Year</label><input type="text" size="4" maxlength="4" name="txtCuryear" id="txtCuryear" /> - <input type="text" size="4" maxlength="4" name="txtNxtyear" id="txtNxtyear" /></p>
<script type="text/javascript">
var sID = document.getElementById('txtCuryear');
sID.onkeyup = function(event) {
document.getElementById('txtNxtyear').value = parseInt(document.getElementById('txtCuryear').value)+1;
}
</script>


I need to display the next year, of the year that is inputted by the user on the current year textbox.

Your help will be greatly appreciated :)

Nile
01-31-2010, 03:18 PM
Try:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
Some Title
</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function plus(id, el){
document.getElementById(id).value = parseInt(el.value) + 1;
}
</script>
</head>
<body>
<form>
<fieldset>
<p>
<label for="txtCuryear">
Academic Year
</label>
<input type="text" name="txtCuryear" id="txtCuryear" />
<input type="text" name="txtNxtyear" id="txtNxtyear" />
</p>
</fieldset>
</form>
<script type="text/javascript">
document.getElementById('txtCuryear').onkeyup = function (){ plus('txtNxtyear', this) };
</script>
</body>
</html>