来自下拉菜单,取决于另一个下拉菜单+ API请求

时间:2019-03-23 08:58:52

标签: javascript php forms select drop-down-menu

我的表单中有3个下拉菜单。 第三个下拉菜单取决于前两个下拉菜单。

下拉菜单1
选择应用程序-app1

Dopdown 2
设置国家/地区-美国

下拉菜单3
选择app1的“美国关键字”

我需要启动api请求以获取 app1

美国关键字
$keyw = apiRequest("keywords/list",
                        array(
                            'idapp' => '37133',  // I NEED Dropdown 1 Value here
                            'country' => 'US'  // I NEED Dropdown 2 Value here

                           )
                         );

任何人都有一个不错的方法,而无需重新加载太多网站? 这是我完整的带有api请求的表格

    <!-- FORM START -->
                <form id="usualValidate" class="form" method="post">
                    <fieldset class="step" id="w1first">
                        <h1>Create Campaign</h1>


<!-- Dropdown 1 -->
                            <div class="formRow fluid">
                        <strong><label>app:</label></strong>
                        <div class="formRight mt12">

                            <div class="span6">
                            <div class="searchDrop">
                            <select data-placeholder="Select App" onchange="updatevariable(this.value)" name="select2" id="select2" class="chzn-select" style="width:350px;" tabindex="2">
                            <option value=""></option>
                                <?php 
                                foreach ($filtered as $row) {

                                 echo '<option value="'.$row['id'].'">'.$row['title'].'</option>'
                               ;}?>
                            </select>
                            </div>  </div>
                            </div></div>


<!-- Dropdown 2 -->
                             <div class="formRow fluid">
                        <strong><label>Country Targeting:</label></strong>
                        <div class="formRight mt12">
                                <div class="span6"><div class="searchDrop">
                            <select data-placeholder="Choose a Country..." name="select1" id="select1" class="chzn-select" style="width:350px;" tabindex="2">
                                <option value="US" selected>United States</option>
                                    <option value="GB">Great Britain</option>
                                    <option value="DE">Germany</option>
                                    <option value="RU">Russia</option>
                                    <option value="IN">India</option>
                                    <option value="CA">Canada</option>
                                    <option value="AU">Australia</option>
                            </select>
                            </div></div>

                            </div></div>


<!-- Dropdown 3 -->
                      <div class="formRow fluid">
                        <strong><label>Keywords:</label></strong>
                        <div class="formRight mt12">

                                <div class="span6"><div class="searchDrop">
                            <select data-placeholder="Select" name="select3" id="select3" class="chzn-select" style="width:350px;" tabindex="2">
                            <option value=""></option>
                                <?php 

                                $keyw = apiRequest("keywords/list",
                                array(
                                       'idapp' => '37133',
                                       'country' => 'US'

                                   )
                                 );
                                foreach ($keyw['keywords'] as $key) {

                                 echo '<option value="'.$key['keyword'].'">'.$key['keyword'].'</option>'
                               ;}?>
                            </select>
                            </div>  </div>
                            </div></div>



                    </fieldset>




                <div class="cLine"></div>
                    <div class="wizButtons"> 
                        <div class="status" id="status1"></div>
                        <span class="wNavButtons">
                        <!-- HIDDEN INPUTS -->
                        <input type="hidden" name="csrf" value="<?=Token::generate();?>" />

                        <!-- HIDDEN END -->

                        <input class="basic" id="back1" value="Back" type="reset" />
                        <input class="blueB ml10" id="submit" value="Next" type="submit" />
                        </span>
                    </div>
                </form>
                <!-- FORM END -->

非常感谢您检查我的线程:)

0 个答案:

没有答案