你好我有一个与单选按钮值有关的问题。首先看一下数组结构
Array
(
[spe_lan] => Array
(
[0] => Russian
[1] => Hebrew
[2] => Tamil
[3] => Vietnamese
)
[spoken] => Array
(
[0] => No
[1] => Yes
[2] => Yes
[3] => Yes
)
[written] => Array
(
[0] => No
[1] => Yes
[2] => Yes
[3] => Yes
)
[set_priamy] => Array
(
[0] => 1
)
[Submit] => Save
[modified] => 2016-06-03 10:02:14
)
在这个数组中我选择4种语言,但只有一种是主要语言,所以我如何得到主要的语言名称。 我使用选择框,其名称取自数组,单选按钮名称也采用数组。请简单地说明我如何实现 我也使用appendTo在点击上添加更多语言请简化 这是我的HTML代码
<form method="post" action="<?php echo $this->webroot?>Jobseeker/add_language" id="add_skills">
<div class="ex-form-edit2" style="display:none;" id="yerte">
<div class="add-skils-form2">
<div class="skill-a-lan">
<h4>Languages <span>*</span></h4>
</div>
<div class="skill-spo">
<h4>Spoken <span>*</span></h4>
</div>
<div class="skill-wri">
<h4>Written <span>*</span></h4>
</div>
<div class="skill-primari">
<h4>Primary <span>*</span></h4>
</div>
</div>
<div id="appendbox">
<div class="add-skils-form">
<div class="skill-a-lan">
<select class="defualt-select default-size" name="spe_lan[]" required>
<option value="" >Select</option>
<option value="Arabic">Arabic</option>
<option value="Bahasa Indonesia">Bahasa Indonesia</option>
<option value="Bahasa Malaysia">Bahasa Malaysia</option>
<option value="Bengali">Bengali</option>
<option value="Chinese">Chinese</option>
<option value="Dutch">Dutch</option>
<option value="English">English</option>
<option value="Filipino">Filipino</option>
<option value="French">French</option>
<option value="German">German</option>
<option value="Hebrew">Hebrew</option>
<option value="Hindi">Hindi</option>
<option value="Italian">Italian</option>
<option value="Japanese">Japanese</option>
<option value="Korean">Korean</option>
<option value="Portuguese">Portuguese</option>
<option value="Russian">Russian</option>
<option value="Spanish">Spanish</option>
<option value="Tamil">Tamil</option>
<option value="Thai">Thai</option>
<option value="Vietnamese">Vietnamese</option>
</select>
</div>
<div class="skill-spo">
<select class="defualt-select default-size" name="spoken[]">
<option value="Yes" >Yes</option>
<option value="No" >No</option>
</select>
</div>
<div class="skill-wri">
<select class="defualt-select default-size" name="written[]">
<option value="Yes" >Yes</option>
<option value="No" >No</option>
</select>
</div>
<div class="skill-primari">
<input type="radio" value="1" name="set_priamy[]" onclick="getvalue();"/>
<a href="#" class="delete-row"><i class="fa fa-trash" aria-hidden="true"></i></a>
</div>
</div>
</div>
<div class="add-skill-row"><span><i class="fa fa-plus" aria-hidden="true"></i> Add Language</span></div>
<div class="ex-form2-row">
<div class="ex-form-field"><input type="submit" value="Save" name="Submit" class="button-default">
<a id="btn_cancel3" name="btn_cancel" href="javascript:void(0);" role="button" onclick="ddggjdg();">Cancel</a></div>
</div>
</div></form>
答案 0 :(得分:0)
如果你想在PHP中获得单选按钮的选择值,请输入代码:
<form action="" method="post">
<input type="radio" name="radio" value="Radio 1">Radio 1
<input type="radio" name="radio" value="Radio 2">Radio 2
<input type="radio" name="radio" value="Radio 3">Radio 3
<input type="submit" name="submit" value="Get Selected Values" />
</form>
<?php
if (isset($_POST['submit'])) {
if(isset($_POST['radio']))
{
echo "You have selected :".$_POST['radio']; // Displaying Selected Value
}
?>