-1
我試圖從表單下拉框(命名集)中選擇一個值後,將所選值的值回顯出來。目前,我沒有運氣。還要注意我使用codeigniter,但我dout這將是問題。JavaScript:打印HTML表單值onChange
<head>
<script type="text/javascript">
function set_boxes()
{
var TestVar = form.sets.value;
alert("TestVar");
}
</script>
</head>
<h1>New Entry</h1>
<?php
echo form_open('log/add_entry');
/*Weight Entry*/
echo form_label('Weight:', 'weight');
echo form_input('weight');
/*Weight Measurement*/
$measurementOptions = array('kg' => 'KG', 'lbs' => 'LBS');
echo form_dropdown('measurement', $measurementOptions, 'kg');
echo " - ";
/*Sets at Weight*/
echo form_label('Sets:', 'sets');
$setOptions = array('' => '', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6',);
$js = 'onChange="set_boxes(this.form);"';
echo form_dropdown('sets', $setOptions, '', $js);