Forum Moderators: coopster
For instance
<form method = "post" action = "saysomething.php">
Type Name:<br>
<input type = "text" name = "username" value = "">
<input type = "submit" value = "Your name">
<input type = "submit" value = "Child's name">
</form>
saysomething.php then looks something like this
<?
if (Your name is clicked){
print "Your name is $username";
}
else {
//Child's name is clicked
print "Your child's name is $username";
}
?>
Is there a way to make this work?
[edited by: coolo at 7:41 am (utc) on Feb. 24, 2004]
<?
if (empty($childsName){
//"Your name" button is clicked
print "Your name is $username";
}
else {
//"Child's name" button is clicked
print "Your child's name is $username";
}
?>
Anyhow, regardless of what button I click, the first part of the if statement is returned. Any thoughts?
formpage.html
<script lang="javascript">
<!--
function subit(which) {
if (which == 1) {
document.myform.action = 'somepage.php?who=1';
} else if (which == 2) {
document.myform.action = 'somepage.php?who=2';
}
document.myform.submit();
}
//-->
</script>
<form method="post" name="myform">
Type Name:<br>
<input type="text" name="username" value = "">
<input type="button" value="Your name" onClick="javascript:subit(1);">
<input type="button" value="Child's name" onClick="javascript:subit(2);">
</form>
somepage.php
<?
if ($_GET['who'] == 1) {
echo "who equals 1";
} else if ($_GET['who'] == 2) {
echo "who equals 2";
}
?>