【发布时间】:2016-12-12 18:27:16
【问题描述】:
我有一个html下拉列表,即选择值时,它会显示一个与选择对应的表。我也有一个添加按钮。添加按钮内有两个需要填写的信息字段,一个是下拉框。这是我需要但无法弄清楚的。我希望我的添加按钮下拉列表中的选定值是第一个下拉列表中已经选择的数字。我该怎么做?
这是我目前的代码:
<button class="ui-button ui-corner-all ui-widget" id="insertButton">Add Supplier ID</button><br><br>
<div id="dialog-form" title="Add Supplier ID">
<p class="validateTips">All form fields are required.</p>
<!-- Dialog box displayed after add row button is clicked -->
<form>
<fieldset>
<label for="mr_name">MR_ID</label>
<select name="mr_id" id="mr_id_dialog" class="text ui-widget-content ui-corner-all" value="300">
<?php foreach($user->fetchAll() as $user1) { ?>
<option>
<?php echo $user1['MR_ID'];?>
</option>
<?php } ?>
</select><br><br>
<label for="buyer_id">Supplier ID</label>
<input type="text" name="supp_id" id="supplier_id" class="text ui-widget-content ui-corner-all" value="99">
<!-- Allow form submission with keyboard without duplicating the dialog button -->
<input type="submit" id="submit" tabindex="-1" style="position:absolute; top:-1000px">
</fieldset>
</form>
</div>
<!-- Form -->
<form name="myForm" action="">
<!-- Dropdown List -->
<select name="master_dropdown" id="mr_id" onChange="updatetable(this.form);">
<option selected value="select">Choose a MR_ID</option>
<?php foreach($users->fetchAll() as $user) { ?>
<option data-name="<?php echo $user['MR_ID'];?>">
<?php echo $user['MR_ID'];?>
</option>
<?php } ?>
</select>
</form>
<!-- Table -->
<p>
<div id="table_div">
<table border="1" id="index_table" class="ui-widget ui-widget-content" style="display: none">
<thead>
<tr class="ui-widget-header">
<td>MR ID</td>
<td>Supplier ID</td>
</tr>
</thead>
<?php foreach($users_one->fetchAll() as $supp) { ?>
<tr>
<td class="mr_id"><div id="dropdown_selection"></div></td>
<td class="supp_id"><?php echo $supp['Supp_ID']?></td>
</tr>
<?php } ?>
</table>
</div>
【问题讨论】:
标签: javascript jquery html dropdown