Jump to content

[SOLVED] sending two values in one select


gwydionwaters

Recommended Posts

one select being a select input type in an html form. i don't know if this should go in a java forum or not..

anyway the title says it all, what i want to do is instead of having

<select name="option1"><option value="$var1"></option></select>

i want to be able to send $var1 and $var2 as option1 in a way that i can use both as their own variable in the script they are sent to.

maybe if i were to send it as "$var1,$var2" as $bundle and then somehow separate the two into their own variables on the other side? i am not sure how to do this, or what to google to learn for that matter

Link to comment
https://forums.phpfreaks.com/topic/139056-solved-sending-two-values-in-one-select/
Share on other sites

yeah, to do what you want, you will have to put them together with some sort of a string seperator and then use explode() on the processing script to split them up.

 

<select name="option1"><option value="<?php echo $var1.','. $var2; ?>"></option></select>

 

On the processing page....

<?php
$splitMe = $_POST['option1'];

$vars = explode(',', $splitMe);

echo 'var1 = '. $var[0];
echo '<br>';
echo 'var2 = '. $var[1];
?>

 

Hope that helps.

 

Nate

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.