I have two buttons named 'go' and 'sub' and one form to do this.At same form i have two click events.
echo "<input type='submit' name='go' id='go' value='Go' />"; // button go
echo "<input type="submit" name="sub" id="button" value="Submit" />"; // button sub
echo "<input type='text' name='type' id='type' value='$router' />"; // This is a texbox. This value-$router pass from a list box
if (isset($_POST['go'])) // when user click on go button
{
$r=$_POST['type'];
echo $r; // this printed $r value.
}
if (isset($_POST['sub']))
{
// problem is...
// How can i get $r value to here...?
echo "Router : ".$r; // I got null value for this
// How can i get $r value to this click event..?
}
How can I pass a veriable -----
Moderator: General Moderators
Re: How can I pass a veriable -----
While your code doesn't really make sense to me, your "$r" variable is actually stored in $_POST['type']. As long as that value is set, you can access it all day. My guess is your problem with "$router". It isn't defined anywhere in the stuff you posted. Or the problem is that the if-loop you're having trouble with runs before or outside of where $r is defined. Try redefining $r=$_POST['type'] inside the if-loop where you are having trouble.
Also, learn to use the [syntax=php]PASTE CODE HERE[/syntax] tags for posting.
Also, learn to use the [syntax=php]PASTE CODE HERE[/syntax] tags for posting.