當前位置:首頁 » 編程語言 » phpradio

phpradio

發布時間: 2022-07-19 04:52:19

php代碼怎麼獲取radio中的value值

radio是html中的單選項標簽,通常放置於form表單中使用,value屬性是標簽的值;
獲得值得兩種方式:
一是在頁面中通過javascript來獲得:為radio加id屬性,然後通過getElementsById(id名').value得到;
二是使用表單的action屬性傳值,使用PHP為通過get或者post方法傳給某頁面,使用$_GET['name名']或$_POST['name名']來獲得。

② php中radio按鈕單選的問題

radio 的 name 相同就可以了
<input type="radio" name="RR" value="1">
<input type="radio" name="RR" value="2">

③ php radio如果不選擇返回什麼值

radio名字作為參數。未選返回false;有選擇項,返回選項值。

④ PHP中怎樣獲取radio單選框的值

html 代碼:

<formaction="index.php"method="post"><!--get方法也是可以的--!>
<inputtype="radio"name="sex"value="f">女
<inputtype="radio"name="sex"value="m">男
<inputtype="submit"name="submit"value="提交">
</form

兩個radio控制項的name屬性必須是一樣的

index.php代碼:

$_POST['sex'];//就是單選框選中的如果使用的是get方法,那麼使用$_GET['sex'];

上面的只是簡單地例子,可以參考一下

⑤ PHP radio是變數,值如何寫入資料庫

請將正常,不正常歸類為一個組

<input type="radio" name="item[0]" value="正常" style="zoom:150%;" />正常
<input type="radio" name="item[0]" value="不正常" style="zoom:150%;" />不正常</td>

下面,每個radio的name依次為item[1],item[1]......

後端處理的時候,將每個item的值依次讀進來,並存入到資料庫即可

⑥ php如何把一個變數設置到表單的radio選項裡面

用戶提交時選中的值,是提交到資料庫中的。
修改資料的時候,從資料庫中讀取提交是的值,然後,再設置此值被選中。
我寫了一個類似的簡化一些的例子,你仿照做,可以解決你遇到的問題。

<!doctype html><html><meta charset="utf-8" /><title>test</title><body><?php$classfy_arr = array('搞笑','萌系','少女');$classfy_selected = '萌系';//此值為演示值 。正確的做法是:從資料庫中讀取出用戶提交信息時,設置的值?><select name="classfiy"> <option>請選擇</option> <?php foreach ($classfy_arr as $val){ ?> <option value="<?php echo $val;?>" <?php if($classfy_selected == $val) echo 'selected';?>><?php echo $val?></option> <?php } ?></select></body></html>

⑦ php 一個頁面有好幾個radio按鈕,怎麼實現radio按鈕切換,檢索條件部分跟在動態切換。

這個是需要用JS來實現的,就類似tap選項卡的效果。下面是找的一個例子,和你想要的效果一樣

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">

<head>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<title>Radio切換效果</title>
<style>
*{margin:0;padding:0;}
body{margin:50px;font-size:12px;color:#666;}
li{list-style:none;}
div{width:210px;}#tab1,#tab2{width:398px;height:34px;border:1px#cfedffsolid;border-bottom:0;background:url(images/title.gif)repeat-x;}#tab1ul,#tab2ul{margin:0;padding:0;}#tab1li,#tab2li{float:left;padding:030px;height:34px;line-height:34px;text-align:center;border-right:1px#ebf7ffsolid;cursor:pointer;}#tab1li.now,#tab2li.now{color:#5299c4;background:#fff;font-weight:bold;}.tablist{width:378px;height:100px;padding:10px;font-size:14px;line-height:24px;border:1px#cfedffsolid;border-top:0;display:none;}.block{display:block;}
fieldset{width:378px;border:1px#B0C0D1solid;padding:10px;}
legend{background:#B0C0D1;padding:4px10px;color:#fff;}#c{margin-top:10px;}.c1,.c2{width:378px;line-height:20px;}.c1{color:#014CC9;}.c2{color:#7E6095;}
h3{font-size:16px;padding:5px0;}.red{color:#BD0A01;}
</style>
</head>

<body>
<h1>Radio切換</h1>
<scripttype="text/javascript">
functionradioShow(){
varmyradio=document.getElementsByName("myradio");
vardiv=document.getElementById("c").getElementsByTagName("div");
for(i=0;i<div.length;i++){
if(myradio[i].checked){
div[i].style.display="block";
}else{
div[i].style.display="none";
}
}
}
</script>
<formname="ck">
<fieldset>
<legend>I'mRadio</legend>
<h3>請選擇:</h3>
<labelfor="r1"class="red">
<inputname="myradio"id="r1"type="radio"value=""checked="checked"onclick="radioShow();"/>XML教程</label>
<labelfor="r2"class="red">
<inputname="myradio"id="r2"type="radio"value=""onclick="radioShow();"/>瀏覽器腳本</label>
<divid="c">
<divclass="c1">
<labelfor="xml">
<inputname="c2"type="checkbox"id="xml"value=""/>XML</label>
<labelfor="dtd">
<inputname="c2"id="dtd"type="checkbox"value=""/>DTD</label>
<labelfor="xmldom">
<inputname="c2"id="xmldom"type="checkbox"value=""/>XMLDOM</label>
<labelfor="xsl">
<inputname="c2"id="xsl"type="checkbox"value=""/>XSL</label>
<labelfor="xslt">
<inputname="c2"id="xslt"type="checkbox"value=""/>XSLT</label>
<labelfor="xslfo">
<inputname="c2"id="xslfo"type="checkbox"value=""/>XSL-FO</label>
<labelfor="xpath">
<inputname="c2"id="xpath"type="checkbox"value=""/>XPath</label>
<labelfor="xquery">
<inputname="c2"id="xquery"type="checkbox"value=""/>XQuery</label>
<labelfor="xlink">
<inputname="c2"id="xlink"type="checkbox"value=""/>XLink</label>
<labelfor="xpointer">
<inputname="c2"id="xpointer"type="checkbox"value=""/>XPointer</label>
<labelfor="schema">
<inputname="c2"id="schema"type="checkbox"value=""/>Schema</label>
<labelfor="xforms">
<inputname="c2"id="xforms"type="checkbox"value=""/>XForms</label>
</div>
<divclass="c2"style="display:none;">
<labelfor="js">
<inputname="c3"id="js"type="checkbox"value=""/>JavaScript</label>
<labelfor="hd">
<inputname="c3"id="hd"type="checkbox"value=""/>HTMLDOM</label>
<labelfor="dhtml">
<inputname="c3"id="dhtml"type="checkbox"value=""/>DHTML</label>
<labelfor="vbs">
<inputname="c3"id="vbs"type="checkbox"value=""/>VBScript</label>
<labelfor="ajax">
<inputname="c3"id="ajax"type="checkbox"value=""/>AJAX</label>
<labelfor="e4x">
<inputname="c3"id="e4x"type="checkbox"value=""/>E4X</label>
<labelfor="wml">
<inputname="c3"id="wml"type="checkbox"value=""/>WMLScript</label>
</div>
</div>
</fieldset>
</form>
</body>

</html>

⑧ PHP,radio取值問題,為什麼取不到radio的值

<?php echo $array[0];?>這樣值就出來了。

<?php $radio_name = $_GET['radio'];
echo $radio_name;
?>
你這個只要是對的,但你要確定$_GET['radio']是有東西的。

熱點內容
青驕如何重置賬號密碼 發布:2025-02-01 09:57:51 瀏覽:520
阿里雲伺服器鏡像市場 發布:2025-02-01 09:46:04 瀏覽:525
任子行伺服器管理口默認地址 發布:2025-02-01 09:42:58 瀏覽:996
設備作為FTP客戶端時 發布:2025-02-01 09:35:07 瀏覽:936
安卓如何登錄ios明日之後 發布:2025-02-01 09:31:59 瀏覽:306
怎麼查看手機存儲卡 發布:2025-02-01 09:31:51 瀏覽:341
java知識點總結 發布:2025-02-01 09:08:32 瀏覽:685
如何在手機版給伺服器加光影 發布:2025-02-01 09:02:14 瀏覽:728
簡單神器安卓系統的哪個好 發布:2025-02-01 09:00:48 瀏覽:355
社保卡密碼如何異地改密碼 發布:2025-02-01 08:57:22 瀏覽:34