我在JSP中創建一個頁面,其中有三個相關的下拉列表 ,一旦用戶從名爲 「縣」的第一個下拉列表中選擇一個值,那麼他必須點擊「下一個」按鈕,然後點擊相關的 值發送到所謂的「行」,那麼他 必須再次點擊「下一步」按鈕,然後將相關值發送 名爲「站」和最後點擊保存按鈕 那麼相關的公司名單將第三下拉列表中第二個下拉列表從選定的最近的 站出現。和我的編碼如下:如何更改程序 - >從「提交按鈕」到「onchange javascript seleced」下拉列表?
<body style="overflow: hidden;padding:5px;border-radius:5px;border:1px solid #777">
<div>
<div>
<span id="wishtxt" style="color:#dd0000;font-size: 150%;display:none"></span>
<form action="<?php echo REQUEST_PATH?>" id="form_eki">
<?php if($h->is_action('index'))://------------------------------------------------------------------------------------------------------------------------?>
<input type="hidden" name="wish">
<div>
<div style="margin-top: 3px;">
<select name="pref" tabindex="6" style="width: auto;">
<option value="">-- select prefecture name --</option>
<?php $h->pr_ops_pref($h->get_target_pref())?>
</select>
<button name="action" value="line" type="submit" tabindex="7">Next</button>
</div>
<?php elseif($h->is_action('line'))://------------------------------------------------------------------------------------------------------------------------?>
<input type="hidden" name="wish">
<input type="hidden" name="pref">
<div>
<div style="margin-top: 3px;">
<select name="pref" tabindex="6" style="width: auto;">
<option value="">-- select prefecture name --</option>
<?php $h->pr_ops_pref($h->get_target_pref())?>
</select>
<button name="action" value="line" type="submit" tabindex="7">Change</button>
</div>
</div>
<?php if($h->d('list_station')):?>
<div style="margin-top: 3px;">
<select name="line" tabindex="8" style="width: auto;max-width: 350px;">
<?php $h->pr_ops_db($h->d('list_line'),'line_cd',"line_name") ?>
</select>
<span>
<button name="action" val2ue="line" type="submit" tabindex="9">Change</button>
</span>
</div>
<?php
$imax = count($h->d('list_station'));
?>
<div style="margin-top: 5px;">
<select id="station_cd" name="station_cd" style="width: auto;max-width: 350px;">
<option value="" selected>-- Select the nearest station--</option>
<?php for ($i=0;$i<$imax;$i++):?>
<option value="<?php $h->pr_d("list_station/$i/station_cd");?>"><?php $h->pr_d("list_station/$i/station_name")?></option>
<?php endfor;?>
</select>
</div>
<div style="margin-top: 5px;">
<button type="submit" name="action" value="clear" tabindex="4">back</button>
<button id="btn_eki" type="button" tabindex="4" style="color:red">save</button>
</div>
<?php elseif($h->d('list_line')):?>
<h3 style="margin-top: 5px;">Select a railway line</h3>
<?php
$company_name = '';
$imax = count($h->d('list_line'));
?>
<div style="margin-top: 3px;">
<select name="line" style="width: auto;max-width: 250px;">
<optgroup label="">
<option value="" selected>-- Select nearest railway line --</option>
<?php for ($i = 0; $i<$imax; $i++):?>
<?php if($h->d("list_line/$i/company_name") != $company_name):?>
<?php $company_name = $h->d("list_line/$i/company_name");?>
</optgroup>
<optgroup label="<?php echo $company_name;?>">
<?php endif;?>
<option value="<?php $h->pr_d("list_line/$i/line_cd")?>"><?php $h->pr_d("list_line/$i/line_name")?></option>
<?php endfor;?>
</optgroup>
</select>
</div>
<div style="margin-top: 3px;">
<button type="submit" name="action" value="clear" tabindex="4">back</button>
<button type="submit" name="action" value="line">Next</button>
</div>
<?php endif;?>
<?php endif;//------------------------------------------------------------------------------------------------------------------------?>
</form>
</div>
</div>
</body>
但現在我想讓它只有三個下拉列表中和「的onChange 選擇」,並不會有按鈕「下一步」,「返回」或「保存」。當 我從第一個下拉列表中選擇「縣」時,自動查詢將 更新爲「行」第二下拉列表,當我選擇第二個 下拉列表,然後自動查找將更新爲「站」第三個 下拉列表,並最終自動保存在後端和相關公司 列表將從選定的最近的站點出現。
感謝您information.I已在下列方式改變,但是當我 選擇從第一個下拉列表的「轄區」,那麼就不會出現所謂的「線」第二個下拉列表 ...任何人可以幫助我梳理出來?
我的javascript:
$(document).ready(function(){
$('#pref_cd').on('change',function(){
$('#line_cd').val('');
$('#station_cd').val('');
$('#form_eki').submit();
return true;
});
$('#line_cd').on('change',function(){
$('#station_cd').val('');
$('#form_eki').submit();
return true;
});
$('#btn_eki').click(function(){
var $option = $('#station_cd option:selected');
var station_cd = $option.val();
window.parent.add_tag(station_cd, "", $('#wishtxt').html(),1);
window.parent.$('#nearStForm' + $('input[name="wish"]').val()).slideUp();
});
$('.close').click(function() {
window.parent.$('#nearStForm' + $('input[name="wish"]').val()).slideUp();
});
$('#btn_clear').click(function(){
});
$('#wishtxt').html($('#form_eki [name="wish"]').val());
});
與我已刪除&變化方案中第一個DropDownList是 所有按鈕:
<select name="pref" id="pref" onChange="this.form.submit()" tabindex="6" style="width: auto;">
<option value="">-- select prefecture name --</option>
<?php $h->pr_ops_pref($h->get_target_pref())?>
</select>
在二下拉列表:
<select name="line" id="line" onChange="this.form.submit()" tabindex="8" style="width: auto;max-width: 350px;">
<?php $h->pr_ops_db($h->d('list_line'),'line_cd',"line_name") ?>
</select>
在第三下拉列表:
<select id="station_cd" onChange="this.form.submit()" name="station_cd" style="width: auto;max-width: 350px;">
<option value="" selected>-- Select the nearest station--</option>
<?php for ($i=0;$i<$imax;$i++):?>
<option value="<?php $h->pr_d("list_station/$i/station_cd");?>"><?php $h->pr_d("list_station/$i/station_name")?></option>
<?php endfor;?>
</select>
感謝您information.I已在上述方式改變,但是當我選擇從第一個下拉列表中的「轄區」,那麼就不會出現所謂的「線」第二個下拉列表...任何人可以幫我整理出來? – Rakib