GIDForums  

Go Back   GIDForums > Webmaster Forums > Web Design Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 26-Jun-2009, 19:19
manishsethi manishsethi is offline
New Member
 
Join Date: Jun 2009
Posts: 5
manishsethi is an unknown quantity at this point

3 submit buttons 3 different destinations


hey friends.... i need some help... i want to create one form... in which i want to have three submit buttons. and the difficulty is these different buttons has different destinations....
means multiple actions in a form.......
and restriction is i must use only HTML coding. no JAVASCRIPT
  #2  
Old 27-Jun-2009, 13:34
MisterChucker's Avatar
MisterChucker MisterChucker is offline
Junior Member
 
Join Date: Mar 2009
Location: Cyberspace, Earth
Posts: 53
MisterChucker is a jewel in the roughMisterChucker is a jewel in the roughMisterChucker is a jewel in the rough

Re: 3 submit buttons 3 different destinations


Give the three submit buttons the same name but different values.
HTML Code:
<form action="director.php" method="post"> <p> <input type="submit" name="go" value="One" /> <input type="submit" name="go" value="Two" /> <input type="submit" name="go" value="Three" /> </p> </form>
Use a switching script (director.php) between the form and the three processing scripts. It is important to use include() rather than header() in the switching script because the POST variables will be lost if you use header().
PHP Code:

<?php
if (isset($_POST['go'])) {
    switch ($_POST['go']) {
        case 'One' :
            include 'a.php';
            break;
        case 'Two' :
            include 'b.php';
            break;
        case 'Three' :
            include 'c.php';
            break;
        default :
            exit;
    }
}
echo '<pre>', print_r($_POST, 1), '</pre>';
?>

  #3  
Old 01-Jul-2009, 02:41
manishsethi manishsethi is offline
New Member
 
Join Date: Jun 2009
Posts: 5
manishsethi is an unknown quantity at this point

Re: 3 submit buttons 3 different destinations


thanks for answer "MisterChucker ".
but if i want to use only Simple HTML then is it possible...
  #4  
Old 01-Jul-2009, 09:12
MisterChucker's Avatar
MisterChucker MisterChucker is offline
Junior Member
 
Join Date: Mar 2009
Location: Cyberspace, Earth
Posts: 53
MisterChucker is a jewel in the roughMisterChucker is a jewel in the roughMisterChucker is a jewel in the rough

Re: 3 submit buttons 3 different destinations


Forms were designed to be submitted to a single processing agent, which is designated by a single URL in the form's action attribute.

W3C: Form Submission

To cause the form to choose among multiple processing agents, a language capable of making decisions must be used in addition to HTML. The language can either be a client-side scripting language like Javascript or a server-side language like PHP. If you want to use a client-side script, change the form action when a submit button is pressed but before the form is submitted. If you want to use a server-side script, have the server figure out which submit button was pressed and include the appropriate processing page.
 
 

Recent GIDBlogNot selected for officer school by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 12:38.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.