Current location: Hot Scripts Forums » General Web Coding » HTML/XHTML/XML » a littel help...


a littel help...

Reply
  #1 (permalink)  
Old 06-30-09, 06:37 AM
reza01 reza01 is offline
New Member
 
Join Date: Jun 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
a littel help...

hi......
I have 2 button.
I want each of them submit form and when open a.php give $id to that page.
for example.
if $id =20: (../a.php?20 ).
Code:
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<title>Untitled 1</title>
</head>

<body>

<form method="post" action="a.php">
    <input name="Button1" type="button" value="button1" /><input name="Text1" type="text"></form>
<p><input name="Button2" type="button" value="button2" /><input name="Text2" type="text"></p>

</body>

</html>
<?php
$id=20;
?>
//../a.php?id=20
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 06-30-09, 07:12 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Is this what you mean?
PHP Code:

<?php
$id 
20;
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<title>Untitled 1</title>
</head>
<body>
<form method="post" action="a.php">
<input type="hidden" name="id" value="<?php echo $id?>">
<input name="Button1" type="submit" value="button1" />
<input name="Text1" type="text">
<p><input name="Button2" type="submit" value="button2" />
<input name="Text2" type="text"></p>
</form>
</body>
</html>
a.php
PHP Code:

<?php
echo $_POST["id"]."<br />";
if(!empty(
$_POST["Button1"]))
{
 echo 
$_POST["Text1"]."<br />";
 }
if(!empty(
$_POST["Button2"]))
{
 echo 
$_POST["Text2"]."<br />";
 }
?>
__________________
Jerry Broughton

Last edited by job0107; 06-30-09 at 07:15 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-03-09, 11:37 AM
reza01 reza01 is offline
New Member
 
Join Date: Jun 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Hello
Very thanks for help

But my main purpose was that when I click button1, $id=20 Post and when click button2 , $id=40 Post

click button1---> (../a.php?id=20 ).
click button2---> (../a.php?id=40 ).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 07-05-09, 09:33 PM
ruteckycs's Avatar
ruteckycs ruteckycs is offline
Coding Addict
 
Join Date: Jul 2009
Posts: 377
Thanks: 6
Thanked 10 Times in 10 Posts
Why not just use a drop down instead of many buttons?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 07-06-09, 01:28 AM
=OTS=G-Man =OTS=G-Man is offline
Newbie Coder
 
Join Date: Jun 2009
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
use a hidden field and javascript on the buttons

I havent had time to test this, and im writting it from memory, so be sure to test.

in your form have a hidden filed like
<input type="hidden" name="id" value="" />

then on your submits have like

<input type="submit" value="Button1" name="button1" onclick"this.id.value=20" />
<input type="submit" value="Button2" name="button2" onclick"this.id.value=40" />
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 07-08-09, 06:09 AM
xEX3CUT1ONx xEX3CUT1ONx is offline
Wannabe Coder
 
Join Date: Jun 2008
Posts: 116
Thanks: 2
Thanked 0 Times in 0 Posts
What I would do is make a little form for each button so,

HTML Code:
<form action='button1.php' method='post'><input type='submit' value='Button 1'><input type='hidden' value='20' name='id20' /></form>
<form action='button2.php' method='post'><input type='submit' value='Button 2'><input type='hidden' value='20' name='id40' /></form>
PHP Code:

//Get Post Variables

$button1 $_POST['id20'];
$button2 $_POST['id40'];

echo 
$button1;
echo 
$button2
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 10:25 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.