Hi
i'm trying to display a default value in a atext field then when user changes it im grabbing it in javascript and passing it as a hidden variable but it doesnt work

//javascript function
function save()
{
var imp = document.getElementById('yesno').checked;
document.getElementById("schdate").value  = document.getElementById('nextsch').value;
if(imp == false)
	{
		<? $impt = 'N' ?>
	}
	else{
		<? $impt = 'Y' ?>
	}
alert ("date"+document.getElementById('schdate').value)
//when i alert it had value
}
//form
<form name="mainform" method="post" action="savesupdet.php?impt=<?= $impt ?>">
<td align='center' width='100'>	
	<input type='text' id='nextsch' name='nextsch' value='<?= $nextsch?>'>&nbsp; </input> </td>
	<input type=hidden name=schdate id=schdate value = 'null'>
	</table>
</form>
	</body>	
</html>
// savesupdet.php file
$cerll = $_POST['cerll'];
	$nextsch = $_POST['schdate'];
	$ta = $_POST['txta'];
	$impt = $_GET['impt'];
	echo $nextsch;
	echo "<br>";
	echo $cerll;
	echo "<br>";
	echo $ta;
	echo "<br>";
	echo $impt;

everything else gets posted though only this is a hidden field i tried everyting else can anyone help????????

on the submit button
<input type="submit" value="Save" name="Save" tabindex="7" style="font-size: xx-small" onclick="save()">
inside the form

<?php
print_r($_POST);
?>
<html>
<head>
<script type="text/javascript">
function save()
{
document.getElementById("schdate").value  = document.getElementById('nextsch').value;
alert ("date"+document.getElementById('schdate').value);
//when i alert it had value
}
</script>
</head>
<form name="mainform" method="post" action="1.php?impt=<?= $impt ?>">
<table>
<tr>
<td align='center' width='100'>	
	<input type='text' id='nextsch' name='nextsch'>&nbsp;</td>
	<input type=hidden name=schdate id=schdate>
	</tr></table>
<input type="submit" value="Save" name="Save" tabindex="7" style="font-size: xx-small" onclick="save();">
	</form>
</body>	
</html>

Check this..

var imp = document.getElementById('yesno').checked;

var imp will always be true with this. You can use if condition or document.getElementById('yesno').value;
Remove value='null'.

This question has already been answered. Start a new discussion instead.