0
如果從下拉菜單中選擇值Others- Not Listed
,我在表單中顯示動態輸入字段。我試圖通過php pdo將這些值插入到名爲courses_selection_list
的mysql表中。我將插入course_id
和course_name
。此值在div .hideNewCourse
內。但不知道如何這樣做,因爲這些值在動態輸入字段內。住DEMO將動態字段值插入到MySQL表中
<form>
<div id="course_catalog">
<div id="course_1">
<label>Course # 1</label>
<br>
<label>Course Name:</label>
<select id="coursename_1" class="course_list" name="coursename_1">
<option value="">--- Select ---</option>
<option value="1">Math</option>
<option value="2">English</option>
<option value="3">Science</option>
<option value="4">Other- Not Listed</option>
</select>
<div class="hideNewCourse" style="">
Add Course Name to List:
<input id="new_course_name_50" class="new_course_name" type="text" name="new_course_name[]">
<input id="new_course_id_50" class="new_course_id" type="hidden" readonly="readonly" name="new_course_id[]" value="50">
</div>
</div>
<br>
<div id="course_2">
<label>Course # 2</label>
<br>
<label>Course Name:</label>
<select id="coursename_2" class="course_list" name="coursename_2">
<option value="">--- Select ---</option>
<option value="1">Math</option>
<option value="2">English</option>
<option value="3">Science</option>
<option value="4">Other- Not Listed</option>
</select>
<div class="hideNewCourse" style="">
Add Course Name to List:
<input id="new_course_name_51" class="new_course_name" type="text" name="new_course_name[]">
<input id="new_course_id_51" class="new_course_id" type="hidden" readonly="readonly" name="new_course_id[]" value="51">
</div>
</div>
</form>
表:courses_selection_list
+-----------+-------------------+
| course_id | course_name |
+-----------+-------------------+
| 1 | Math |
| 2 | English |
| 3 | Science |
| 4 | Other- Not Listed |
+-----------+-------------------+
這工作得很好,更有意義。謝謝! –