如何将程序-->从“提交按钮”更改为“onchange javascript seleced”下拉列表?
我正在用JSP创建一个页面,其中有三个相关的下拉列表 一旦用户从第一个下拉列表中选择了一个名为 然后他必须单击“下一步”按钮,然后单击 相关的值被发送到第二个名为line的下拉列表中,然后发送到he 必须再次单击“下一步”按钮,然后发送相关值 到第三个名为station的下拉列表,最后单击save按钮 然后,相关公司列表将从所选最近的公司列表中显示 火车站我的代码如下:如何将程序-->从“提交按钮”更改为“onchange javascript seleced”下拉列表?,javascript,php,select,drop-down-menu,onchange,Javascript,Php,Select,Drop Down Menu,Onchange,我正在用JSP创建一个页面,其中有三个相关的下拉列表 一旦用户从第一个下拉列表中选择了一个名为 然后他必须单击“下一步”按钮,然后单击 相关的值被发送到第二个名为line的下拉列表中,然后发送到he 必须再次单击“下一步”按钮,然后发送相关值 到第三个名为station的下拉列表,最后单击save按钮 然后,相关公司列表将从所选最近的公司列表中显示 火车站我的代码如下: <body style="overflow: hidden;padding:5px;border-radius:5px;
<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>
我已经删除了所有按钮&更改程序
在第一个下拉列表中:
在第二个下拉列表中:
在第三个下拉列表中:
更改地区时调用javascript函数,其中调用ajax功能。在此ajax调用中,执行与表单提交中执行的操作相同的操作。ajax调用成功后,填充第二个下拉列表,并使用第二个下拉列表执行相同的操作。感谢您提供的信息。我已以上述方式进行了更改,但当我从第一个下拉列表,然后第二个名为line的下拉列表将不会出现。。。有人能帮我解决吗?
$(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());
});
<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>