行动表格不起作用

时间:2016-02-08 05:19:32

标签: php html forms

<form action="/en2/maps-<?php echo $id; ?>/?=. ($_GET['textSearchTerms']).&=. ($_GET['locationSearchTerms'])."><!--Relative url to the page that your map is on-->

Distination: 
<select name="textSearchTerms" class="selectpicker" data-live-search="true">
        <option value="alfamart">Alfamart</option>
        <option value="BCA">BCA</option>
    </select> 
Location: 
<input type="text" name="locationSearchTerms">

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

<form action="/en2/maps-<?php echo $id; ?>无效...... 任何想法?

我希望此链接用于表单操作:

http://indonesia.com/en2/maps-alfamart/?textSearchTerms=alfamart&locationSearchTerms=denpasar

感谢

2 个答案:

答案 0 :(得分:1)

像这样使用

    <?php
        $id="alfamart";
        $textSearchTerms = isset($_GET['textSearchTerms']) ? $_GET['textSearchTerms'] : "";
        $locationSearchTerms = isset($_GET['locationSearchTerms']) ? $_GET['locationSearchTerms'] : "";
        $url = "/en2/maps-".$id."/?textSearchTerms=".$textSearchTerms."&locationSearchTerms=".$locationSearchTerms;
    ?>
    <form action="<?php echo $url; ?>" method="GET">
    Distination:
    <select name="textSearchTerms" class="selectpicker" data-live-search="true">
            <option value="alfamart">Alfamart</option>
            <option value="BCA">BCA</option>
        </select>
    Location:
    <input type="text" name="locationSearchTerms">
    <input type="submit" value="Search">
    </form>

在php标签中添加了表单方法GET和你的php变量

答案 1 :(得分:0)

替换

<form action="/en2/maps-<?php echo $id; ?>/?=. ($_GET['textSearchTerms']).&=. ($_GET['locationSearchTerms']).">

<form action="/en2/maps-<?php echo $id; ?>/?textSearchTerms=<?php echo $_GET['textSearchTerms']; ?>&locationSearchTerms=<?php echo $_GET['locationSearchTerms']; ?>">

注意: - 您在textSearchTerms之前的表单操作参数中错过了locationSearchTerms=