Forum Moderators: open
<html>
<head>
<script type="application/JavaScript">
function resetForm(){
var checkbox = document.MercyForm.elements["cb"];
var aomPreset = new Array;
<?php for($i=0;$i<count($aomPreset); $i++){ echo "aomPreset[$i]='".$aomPreset[$i]."';\n\t"; } ?>
if(window.confirm("Reset the form?")){
document.MercyForm.distance.value= <?php echo "'".$milPreset."';"; ?>
document.MercyForm.zipcode.value= <?php echo "'".$zipPreset."';"; ?>
for(i=0; i < checkbox.length; i++){
if(aomPreset[i] == "1" ){checkbox[i].checked = true;}else{checkbox[i].checked = false;}
}
return(true);
}else{
return(false);
}
}
</script>
</head>
<body>
<html>
<html>
<head>
<script type="application/JavaScript" scr="scripts/keypad.js"></script>
</head>
<body>
<html>
<?php
//>keypad.php
//output appropriate header
header('Content-type: text/javascript');
//you would need to have the definition of $aomPreset in this "keypad.php" file...
//as well as definitions for $milPreset and $zipPreset, this may be a problem for
//you if you are deriving them from submitted form values, in which case you
//could pass them to this script with url variables appended to the script tags src, see later script tag info
$aomPreset = array(1, 2, 3);
$milPreset = 'something';
$zipPreset = 'or other';
function resetForm(){
var checkbox = document.MercyForm.elements["cb"];
var aomPreset = new Array;
<?php for($i=0;$i<count($aomPreset); $i++){ echo "aomPreset[$i]='".$aomPreset[$i]."';\n\t"; } ?>
if(window.confirm("Reset the form?")){
document.MercyForm.distance.value= <?php echo "'".$milPreset."';"; ?>
document.MercyForm.zipcode.value= <?php echo "'".$zipPreset."';"; ?>
for(i=0; i < checkbox.length; i++){
if(aomPreset[i] == "1" ){checkbox[i].checked = true;}else{checkbox[i].checked = false;}
}
return(true);
}else{
return(false);
}
}
?>
<script type="text/javascript" src="scripts/keypad.php"></script>
<script type="text/javascript" src="scripts/keypad.php?milPreset=<?php echo $milPreset; ?>&zipPreset=<?php echo $zipPreset; ?>"></script>
<?php
//>keypad.php
//output appropriate header
header('Content-type: text/javascript');
//you would need to have the definition of $aomPreset in this "keypad.php" file...
//as well as definitions for $milPreset and $zipPreset, this may be a problem for
//you if you are deriving them from submitted form values, in which case you
//could pass them to this script with url variables appended to the script tags src, see later script tag info
$aomPreset = array(1, 2, 3);
$milPreset = 'something';
$zipPreset = 'or other';
//exit php code temporarily, or else we could just echo the entire resetForm function..
?>
function resetForm(){
var checkbox = document.MercyForm.elements["cb"];
var aomPreset = new Array;
<?php for($i=0;$i<count($aomPreset); $i++){ echo "aomPreset[$i]='".$aomPreset[$i]."';\n\t"; } ?>
if(window.confirm("Reset the form?")){
document.MercyForm.distance.value= <?php echo "'".$milPreset."';"; ?>
document.MercyForm.zipcode.value= <?php echo "'".$zipPreset."';"; ?>
for(i=0; i < checkbox.length; i++){
if(aomPreset[i] == "1" ){checkbox[i].checked = true;}else{checkbox[i].checked = false;}
}
return(true);
}else{
return(false);
}
}
I did miss was the need to jump in and out of php code there