开发者

How to get two Dropdown Menus to submit to a Dynamic PHP Page

I have a php page that reads data of a particular month/date to a page. But to select the month/date i have 2 dropdown menus as follow.. how do i then load send the month/year values to the page? get/post doesn't matter. Just dk how to 'submit' to that said page.

function select_dates(){
    $html = "Select month: ";
    $html .= 
    '<select name="month">
      <option value="01">January</option>
      <option value="02">Febuary</option>
      <option value="03">March</option>
      <option value="04">April</option>
      <option value="05">May</option>
      <option value="06">June</option>
      <option value="07">July</option>
      <option value="08">August</option>
      <option value="09">September</option>
      <option value="10">October</option>
      <option value="11">November</option>
      <option value="12">Decemeber</option>
    </select>';
    $html .= "Select year: ";
    $html .= 
        '<select name="year">
          <option value="2009">2009</option>
          <option value="2010">2010</option>
          <option value="2011">2011</option>
        </select> ';

    $html .=
开发者_如何学Go    '   <input type="submit" value="Submit" />
        </form>';
    echo $html;


The submit button does nothing unless your opening form tag is declared correctly, in your code I can't see it :)

Make sure you follow this:

<form method="post" action="processingFile.php">
<input... />
</form>

processingFile.php is the PHP file that you want it to handle your form.

Put everything together

function select_dates(){
    $html = "<form method='post' action='processingFile.php'>";
    $html .= "Select month: ";
    $html .= 
    '<select name="month">
      <option value="01">January</option>
      <option value="02">Febuary</option>
      <option value="03">March</option>
      <option value="04">April</option>
      <option value="05">May</option>
      <option value="06">June</option>
      <option value="07">July</option>
      <option value="08">August</option>
      <option value="09">September</option>
      <option value="10">October</option>
      <option value="11">November</option>
      <option value="12">Decemeber</option>
    </select>';
    $html .= "Select year: ";
    $html .= 
        '<select name="year">
          <option value="2009">2009</option>
          <option value="2010">2010</option>
          <option value="2011">2011</option>
        </select> ';

    $html .=
    '   <input type="submit" value="Submit" />
        </form>';
    echo $html;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜