Jump to content

Combining two <select> in a function


Don.

Recommended Posts

[code]
<?php
  if (!isset($_POST['submit'])) {
    echo "<form method='post'>";
    echo "select the hour";
    echo "  <select name='hours'>";
    for ($i = 0; $i < 24; $i++) {
      echo "    <option value='$i'>$i</option>";
    }
    echo "  </select>";
    echo "select the minute";
    echo "  <select name='minutes'>";
    for ($i = 0; $i < 60; $i++) {
      echo "    <option value='$i'>$i</option>";
    }
    echo "  </select>";
    echo "  <input type='submit' value='submit'>";
    echo "</form>";
  } else {
    if (isset($_POST['hours']) && isset($_POST['minutes'])) {
      echo "the time selected was " . $_POST['hours'] . ":" . $_POST['minutes'];
    }
  }
?>
[/code]
Hi Thorpe,

Thanks for the reply.

Unfortunately ive got several dates and times on the page, so it would be impractical to ask the user to click submit each time they set a date or time.

I'll just use individual selects and then combine the results once the form has been posted.

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.