Jump to content

Multiple values under one menu item


Sinbad_Sakic

Recommended Posts

Sorry for that :-[

 

Here's the example:

<html>

<head>

<title>Just a test</title>

</head>

<body>

<form method="post" action="script.php">

Choose site size:

  <select name="option" id="option">

    <option value="First value">First value</option>

    <option value="Second value">Second Value</option>

    <option value="Third value">Third Value</option>

  </select>

  <input type="submit" />

</form>

</body>

</html>

 

I want to attach two variables under (for example) First Value, so when it posts to another page, the result will be:

-First value

-something else

 

I hope now is better :)

 

Thanks in any case!

You can put whatever you want in the value clause and then parse it to get the two values:

<html>
<head>
<title>Just a test</title>
</head>
<body>
<form method="post" action="script.php">
Choose site size: 
  <select name="option" id="option">
    <option value="First value,another value">First value</option>
    <option value="Second value">Second Value</option>
    <option value="Third value">Third Value</option>
  </select>
  <input type="submit" />
</form>
</body>
</html>

The in script.php

<?php
$option = explode(',',$_POST['option']);
echo '<pre>' . print_r($option,true) . '</pre>';
?>

 

Ken

I understand the first part. But the link.php file I use looks like this:

Let's say the first value we named first and second - second

 

<?php

  $first = $_REQUEST['first'] ;

  $second = $_REQUEST['second'] ;

  header( "Location: http://www.somedomain.com/$first$second" );

?>

 

The link which user is going to be redirected will depend on what the user selected.

Where did that come from? You didn't mention that in the original post. Also please use


tags around your code, not

 

<?php
  $first = $_REQUEST['first'] ;
  $second = $_REQUEST['second'] ;
  header( "Location: http://www.somedomain.com/$first$second" );
?>

 

Ken

Sorry again

 

I barely know php but at the moment I'm forced to do some things with it. That's why I am asking so dull questions. :-[

 

How can I request first and second values from the list menu?

 

EDIT: first and second - I mean when we do the following:

<option value="First value,another value">First value</option>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.