我需要將選擇輸入分爲兩部分,以便在同一頁面上使用一個部分創建動態表格,第二部分爲發送到接收表格。在頁面上動態創建表格以及將值發送到表格
這是我現在有動態創建的div下面,基於選擇輸入選擇:
$a = 0;
while ($row = mysql_fetch_array($result)) {
$people_array[$a] = array(
"ID" => $row['ID'],
"event" => $row['name'],
"time_needed" => $row['time_needed'],
);
$a = $a + 1;
}
$count = count($people_array);
<form>
<?php for($p=0,$p<$count,p++){
$segment_id = $people_array[$p][ID]; ?>
<select name="name_segment" id="name_segment">
<option value="female" >
<?php echo $people_array[$p][name]; ?>
</option>
<option value="male" >
<?php echo $people_array[$p][name]; ?>
</option>
</select>
<?php } ?>
</form>
<div id="name_segment_female" class="name_segment_input" style="display:none;">
Allow at least 30 extra minutes for bathroom usage.
</div>
<div id="name_segment_male" class="name_segment_input" style="display:none;">
No extra bathroom time needed.
</div>
和JavaScript
<script>
$("#name_segment").change(function() {
var name_segment = $(this).val();
$(".name_segment_input").hide();
$("#name_segment_" + name_segment).show("slow");
});
</script>
搜索這裏計算器,我發現this post那讓我從這開始:<option value="{type:'amount',segment_id:'<?php echo $segment_id; ?>'} >
。我只需要知道如何在提交頁面之前使用JavaScript分割這個對象。我需要使用選項輸入中的相同值動態顯示隱藏的div,作爲將發送到表單的接收頁面的更具體的值。