The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 21, 2019, 02:33:26 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: HTML form question  (Read 2915 times)
krustee
Rookie
**
Offline Offline

Posts: 33


View Profile
« on: September 20, 2009, 07:59:08 PM »

Jeez it seems like I'm just abusing this n00b section to get answers to my retartedness.

I'm not sure if this was possible but I just spent about an hour trying to figure it out myself (lies about half hour), OK on to my question;

I have a html form with the entries in a drop down menu like this;

Code:
<option label="option label" value="666">option label</option>

I am then using the GET method to send this to a PHP script. example code;

Code:
if(isset($_GET['SubmitForm']))
{
$variable = $_GET['ID'];
}

Basically I am trying to find a way to also send the form label to the PHP script as well and not just the value. I'm sure this is possible but I don't have a clue how to go about it. I'm suspecting some javascript might help me out D'oh!

Well if anyone could point me in the right direction or just tell me if its not possible it would be much appreciated. Oh and before you ask I cant rewrite the HTML form, the dropdown menu has 1000's of entries.

Logged
isthisthingon
Global Moderator
Lifer
*****
Offline Offline

Posts: 2879



View Profile
« Reply #1 on: September 20, 2009, 08:28:58 PM »

Quote
<option label="option label" value="666">option label</option>

Not my area of expertise, but you might try seeking advice from your pastor  Grin
Logged

I would love to change the world, but they won't give me the source code.
krustee
Rookie
**
Offline Offline

Posts: 33


View Profile
« Reply #2 on: September 20, 2009, 08:35:25 PM »

Logged
isthisthingon
Global Moderator
Lifer
*****
Offline Offline

Posts: 2879



View Profile
« Reply #3 on: September 20, 2009, 09:42:44 PM »

You have no idea how perfect that response was  ROFLMAO ROFLMAO ROFLMAO
Logged

I would love to change the world, but they won't give me the source code.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #4 on: September 21, 2009, 12:07:32 AM »

Since you are not defining a VALUE for the option, the text inside the option is what is being sent.

Rather than having a "label" in the option, try something like this:

<form method="post">
<select size="1" name="theSelect">
<option value="somedata|moreData|theUniqueID|andMoreStuff">User Sees This</option>
</select>
</form>

... then when the form is sent, the $_POST value will be named 'theSelect' and have a value of 'someData|moreData|theUniqueID|andMoreStuff' - then you could simply explode that like this: $parts = explode('|', $_POST['theSelect']) and you'd have all the components that you wanted sent up to you.

Is that what you're looking for?
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
deregular
Expert
****
Offline Offline

Posts: 172


View Profile
« Reply #5 on: September 21, 2009, 12:49:29 AM »

^^^^ thats the way Ive done this in the past also.
Logged
krustee
Rookie
**
Offline Offline

Posts: 33


View Profile
« Reply #6 on: September 21, 2009, 04:59:44 AM »

Ok so I got this to work. Thanks for all the help perkiset you are legend in my book. I am just an just stranger coming in here with stupit questions and you are helping me.

Solution documentation:
Originally my html form was like this;
Code:
<option label="option label" value="666">option label</option>

This list was very long so I just done a regex for
Code:
" value="
and replaced it with a delimiter | like perk said.

Next I found and replaced all instance of label with value and voila.

On a side note I installed a regex find and replace plugin for gedit and it seems very useful, it can be found here: http://live.gnome.org/Gedit/Plugins#third_party
« Last Edit: September 21, 2009, 05:06:17 AM by krustee » Logged
jammaster82
Lifer
*****
Offline Offline

Posts: 666


Thats craigs list for ya


View Profile
« Reply #7 on: September 21, 2009, 05:28:25 AM »

Jeez it seems like I'm just abusing this n00b section to get answers to my retartedness.


You cant possibly outdo what i have done to this same effect   ROFLMAO

Be encouraged to post, helps everyone now and down the road that is trying to learn as well...
Logged

The watched pot, never boils... But if you walk away from it , the soup burns.  What gives?
jairez
Expert
****
Offline Offline

Posts: 164


JTFC


View Profile
« Reply #8 on: November 10, 2009, 11:43:59 AM »

Quote
I am just an just stranger coming in here with stupit questions and you are helping me.
You'll realize enlightenment when, like myself, your posts consist only of obscure movie quotes and some snappy retorts.

Wait a second ... I'm a tard.  Who am I kidding?

Question away, young Jedi!!
Logged

Spontaneity has it's time and place.  [Sluggo, 1990-ish]
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #9 on: November 10, 2009, 11:49:27 AM »

 ROFLMAO
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!