HansMuff HansMuff - 5 months ago 26
HTML Question

HTML Form with 2 list boxes

following problem. I have one listbox with value ('FirstValue', 'SecondValue', 'ThirdValue') and another one with ('D','E'). Now, I want to build a submit form with one submit button which POST one value from the first listbox and one value from the second listbox. How to do this with html and php? Can anyone give me an easy example?

Example first listbox -> SecondValue and Second listbox -> E.
After click on the submit button I need something like var = 'SecondValue', 'E'!

Answer Source

This might help.

HTML Form:

<form action="f.php" method="post">
  <select name="lb1">
    <option value="FirstValue">FirstValue</option>
    <option value="SecondValue">SecondValue</option>
    <option value="ThirdValue">ThirdValue</option>
  </select>

  <select name="lb2">
    <option value="D">D</option>
    <option value="E">E</option>
  </select>

  <input type="submit" value="Submit" >
</form>

f.php

<?php
  $var = array($_POST['lb1'], $_POST['lb2']);
?>