1. No Profile Picture
    Super Moderator
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2009
    Hartford, WI
    Rep Power

    Multiple Submit button actions

    Howdy. I simply have 1 form doing 3 things. When a company is selected from a previous list, it arrives at this Profile page, which contains Company Name, Number, ... in a "View" mode. The button displayed at bottom here adjusts it to "Edit" mode, setting everything in text boxes/drop-downs. If someone clicks "Add new..." from the list page, they arrive at this same "Edit" mode, but with blank fields.

    Now, I currently have this building the "Submit" button at bottom:
    PHP Code:
    if($_GET['action'] == 'add') { ?>
                                  <INPUT type="button" value=" Add " onClick="parent.location='?loc=rolodex&action=create&id=<?php echo $companyID?>'" />
                                  <?php } elseif($_GET['action'] == 'view') { ?>
                                  <INPUT type="button" value=" Edit " onClick="parent.location='?loc=rolodex&action=edit&id=<?php echo $companyID?>'" />
                                  <?php } elseif($_GET['action'] == 'edit') { ?>
                                  <INPUT type="button" value=" Update " onClick="parent.location='?loc=rolodex&action=update&id=<?php echo $companyID?>'" />
                                  <?php ?>
    But I assume this will not truely SUBMIT the content of the form, since its relation is meerly button. Does anyone have a suggested way of how I can pull off my goal? The 2 options I was thinking so far was either creating an if/then/else to define the form's action attribute, or provide a hidden item. Any better suggestions, perhaps?
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Rep Power
    Either of the two options you came up with are fine solutions.

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo