Multiple Submit Buttons on Forms: Part II

This is Part II in a discussion on how to incorporate multiple submit buttons on html forms.

Part I focused on having multiple submit buttons that performed completely different actions, such as going to different web pages.  Here we consider multiple submit buttons that launch the same php application, but take different actions within that application.

Here we have a simple form with three submit buttons:

<form name=”categories” method=”get” action=”action.php”>
<input type=”submit” name=”Submit_1″ value=”Submit”>
<input type=”submit” name=”Submit_2″ value=”Submit”>
<input type=”submit” name=”Submit_3″ value=”Submit”>
</form>

I am using the get method so that you can see what actually gets sent along with the url.
When you click on Submit_1 you see this URL:

http://www.urlkazoo.com/action.php?Submit_1=Submit

You can see that it is passing the name of the Submit button as a parameter.  To use this information, one simply needs to identify which parameter is being passed.  We can do this in the php code in action.php.  Here is a php snippet:

// Test is Submit_1 is defined
if (isset($_REQUEST["Submit_1"]))
{
$button = 1;
}
// Test is Submit_2 is defined
if (isset($_REQUEST["Submit_2"]))
{
$button = 2;
}
// Test is Submit_3 is defined
if (isset($_REQUEST["Submit_3"]))
{
$button = 3;
}

Of course the code above can be simplified using else statements.
But the point is to demonstrate that we can determine which button was pressed by figuring out which button’s name has been passed along as a parameter.

From here you can go on to perform different functions based on which submit button was pressed.

Good Luck!

Posted under Coding, Internet, Programming, Software, Space, Uncategorized

Why doesn’t my CSS work?

It seems that I am always banging my head against the CSS wall screaming “What is wrong with my CSS code?” and “Why doesn’t it work?” Today I came across the blog CSSNewbie and they had a nice article on the top five reasons why CSS doesn’t work.

The basic reasons are:

  1. Missing bracket
  2. Missing semicolon
  3. Misspelled Class or ID
  4. Misspelled Properties or Value
  5. Bad CSS Value

Guess which one haunted me?

#1 of course!
What I didn’t know is that CSS loads until there is an error and then it stops.  I had a CSS file that I linked to in the <head> section of my page and after it I had some style tags with some additional CSS definitions.  I saw that half of my CSS stylesheet worked and the other half didn’t, but the commands listed after the included stylesheet worked.  So I was very confused.

It turns out that the CSS stylesheet stopped loading after the parse error, so only the commands defined in the beginning worked.  But when it got to the new style tags, it read those just fine.

To find the error, I used a CSS Validator.
Specifically, I went to:

W3C CSS Validation Service
http://jigsaw.w3.org/css-validator/

and gave it the URI to my CSS stylesheet.
They found the error.

Good Luck!

Posted under Coding, Internet, Programming, Software

This post was written by drknuth on February 18, 2009

Tags:

Multiple Submit Buttons on Forms

I recently encountered the challenge of including multiple submit buttons on an html form.  Wading through the noise on various blogs and help sites was painful.  I finally found the following solution that works, and decided to post this little tutorial…

<form name=myFORM type=post action=default.html>

<input type=’submit’ value=’Open Default Site’ onclick=”this.form.target=’_blank’;return true;”>
<input type=’submit’ value=’Open Special Site’ onclick=”myFORM.action=’special.html’; return true;”> </form>

Note that the default action of the form is defined in the first line by:
action=default.html
Both buttons are of type Submit, but they have different values, which reflect what the buttons actually say.

The command in the first button
onclick=”this.form.target=’_blank’;return true;”
instructs it to follow the default action, which is to open default.html in a new window (indicated by target=’_blank’).

The command in the second button
onclick=”myFORM.action=’special.html’; return true;”
instructs it to take on a new action, which is to open special.html

You can keep adding additional submit buttons this way.

Posted under Coding, Internet, Programming, Software, Solutions

This post was written by drknuth on February 14, 2009

Tags:

Using Gmail as Your Universal Email Account

I have begun to use gmail as my universal email account.  I currently have emails from three different addresses converging into my gmail.  It is easy to set up.  Follow the instructions in the tutorial below:

Tutorial: Gmail as universal email

Gmails excellent spam filters outperform those used by the university.  This has saved me a lot of time as I no longer have to go through hundreds of emails a day.  In addition, I can use gmail to send email from any one of my accounts by using the “Send From” drop-down menu.

Easy!

Posted under Internet, Solutions, Technology

This post was written by drknuth on February 4, 2009

Tags: , , , , ,

Top 10 Things you Forgot Gmail Can Do

The blog Time! reminds us about the capabilities of Gmail.

The full article is here

10. Change Gmail’s look entirely with themes
9. Launch video and audio chats, no Skype required
8. Back up your email from any system
7. See all the places where you’re signed in, and remotely sign out
6. Serve as a central, synchronized, smarter contact list
5. Consolidate all your email accounts
4. Help friends find their own Gmail messages or bookmark your own
3. Keep your Gmail account(s) on your desktop
2. Give you total search power
1. Do much, much more with Gmail Labs experimental features

Posted under Internet

This post was written by drknuth on February 3, 2009

Tags: