Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with drop down menu

Status
Not open for further replies.

egmweb

Programmer
Mar 19, 2004
147
EU
Hello All.
Please help me with this code...

I'm making a drop down menu (<SELECT....)

I have also 3 options and each one has a value such a 1, 2 or 3.

The form method is get. My question is... I need to pass 2 variables, id=2 y id2=21 when I press bottom sumbit selecting only 1 option.

Here is the code, I'm making:

<select name="events">
<option selected>- Selecciona -</option>
<option value="1">Carnaval 2005 - Puerto La Cruz - 07/02/05</option>
<option value="2">Semana Santa 2005 - Margarita - 24/03/05</option>
<option value="3">Barranco Sport en Musipan - 26/03/05</option>
</select>

I need that when I select option 2, throught method get, I can pass to the next page 2 variables... id=2 and id=21

Thanks you.
 

Yes - why? If the only criteria for passing this extra variable is that id must equal 2, then why not bypass the whole addition thing, and simply detect on the next page if id=2 or not. It'd be a lot easier, IMHO.

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Hello all, thanks you for your comments,

Ok. I´m going to explain you at all.

In the first page, I have the form and <SELECT... I´ve mentioned above. This select have 3 options, When the user select the first option it should have pass to the next page id=1 and id2=11, If the user select opcion 2 the form should pass to next page id=2 and id2=21 and with the third option it should pass to next page id=3 and id2=31.

This is because in the next page I have an php script which detect this id values for make a query and extract one of the 3 options of the database.

Thanks you for all help you can provide me.
 
Why not alter the script so that it knows what to set id2 to?

Code:
<?php

switch ($id) {
    case "1":
        $id2="11";
        break;
    case "2":
        $id2="21";
        break;
    case "3":
        $id2="31";
        break;

}
?>

If the value of id2 can be deduced then do the work in the PHP rather than struggling with passing data to the script.

Foamcow Heavy Industries - Web design and ranting
Toccoa Games - Day of Defeat gaming community
Target Marketing Communications - Advertising, Direct Marketing and Public Relations
"I'm making time
 
Isn't it easier if you just do on your php page:
Code:
switch ($id)
{
  case 1:
    $id2 = 11;
    break;
  case 2:
    $id2 = 21;
    break;
  case 3:
    $id2 = 31;
    break;
  default:
    $id2 = 01;
}
 

Absolutely. Any data processing like this is always best done server-side, IMHO, in case JavaScript is disabled.

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Thanks you everybody...

That's the solution... switch function...

Thanks you again guys!!



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top