『壹』 js兩個radio,選擇的問題
if(a==1)
{
document.getelementById("Ra1").checked=true;//男選中
document.getelementById("Ra1").checked=false;//女不選中
}
else
{
document.getelementById("Ra1").checked=false; //男不選中
document.getelementById("Ra1").checked=true;//女選中
}
『貳』 js編寫注冊表,性別以單選鈕選擇輸入,密碼框顯示不可見字元
不需要js好不
<form action="" method="post">
用戶名:
<input type="text" name="username" />
<br />
密碼:
<input type="password" name="pwd" />
<br />
性別:
男
<input type="radio" name="sex" value="男" />
女
<input type="radio" name="sex" value="女" />
<input type="submit" value="提交" />
</form>
『叄』 js性別驗證 求解!!
2個問題
radio控制項要用數組,
if(form.u_sex[0].value!="f" && form.u_sex[1].value!="m"){alert("請選擇性別");
這個還不行,上面的條件是沒有內判斷作用的容,,你在函數checkpost() 里加入
alert(form1.u_sex[0].value);
alert(form1.u_sex[1].value);
就知道了
正確的判斷語句為 if(!form1.u_sex[0].checked && !form1.u_sex[1].checked)
『肆』 用JS做一個彈出框。顯示內容為選擇性別,該怎麼處理
用JS做一個彈出框。顯示內容為選擇性別 就是日歷控制項一樣,當滑鼠在文本框中一點。那麼就彈出一個小框框。選擇性別:男或女 按了男或女之後。將內容回填到滑鼠點中的那個文本框中。 ------解決方案--------------------用模式窗口的例子: 第一個頁面:<html><body>單擊選擇性別: <input type = "text " name = "userSex " readOnly onclick= "loadSmallWindow(this) " code= " "></body><script language= "javascript "> function loadSmallWindow(obj){var returnValue = showModalDialog( "second.html ",window, "dialogWidth:150px;dialogHeight:90px;status:no "); document.all( "userSex ").value = returnValue;}</script></html>窗口頁面second.html:<html><body><select name = "sel_sex "> <option value = "男 "> 男 </option> <option value = "女 "> 女 </option></select><input type= "submit " value = "確定 " onclick= "aa() "></body><script language= "javascript "> window.returnValue = " "; function aa(){window.returnValue = document.all( "sel_sex ").value; window.close();}</script></html>------解決方案--------------------用層做的例子:<html><body><div id= "div " style= "width:150px;height=90px;display:none;background-color:#ffffee;boder-collapse:collapse;border-color:#000000;border-style:solid;border-width:1px;position:absolute;z-index:100 "> <select name = "selSex "> <option value = "男 "> 男 </option> <option value = "女 "> 女 </option> </select> <input type= "button " name = "btnOk " value = "確定 "> </div> 單擊選擇性別:
『伍』 js彈出框顯示請選擇 性別和單選按鈕男女和一個確認按鈕 如何實現
js中alert()方法就可以實現這種效果。種效果常用於表單驗證時彈出提示信息。
下面是用jquery編寫的表內單驗證的簡單例子容:
<html>
<body>
<scripttype="javascript/text"src="jquery.js"></script>
<formid="form"method="post"action="">
性別:男<inpyttype="radio"name="sex"value="0">女<inpyttype="radio"name="sex"value="1">
<inpyttype="button"id="button"value="提交">
</form>
<scripttype="javascript/text">
$("#button"),click(function(){//提交按鈕被點擊觸發
if($("input[name='sex']").is("checked")){//獲取name為sex的input的對象並判斷是否被選中
$("#form").submit();");//如果性別的單選按鈕有被選擇則提交表單
}else{
alert("請選擇性別");//如果性別的單選按鈕沒有被選擇則彈出提示
}
});
</script>
</body>
</html>
『陸』 js性別選擇問題
if(sex[i].checkbed){
改為
if(sex[i].checked){
細心啊!
『柒』 js 性別判斷 textarea下面有個按鈕如果是男點擊按鈕在下面的textarea中輸出內容如果是女輸出另一些內容
<%
Dim Sex
Sex="女"
%>
<textarea id="Con" name="Con" rows="6" cols="60"></textarea>
<input type="button" value="顯示" onclick="ShowMsg();">
<script>
function ShowMsg()
{
var sex='<%=Sex%>';//你通過網傳過來的性別,男或女
var Con=document.getElementById('Con');
版if (sex=='男')
{
Con.value='我是男生權';
}
else
{
Con.value='我是女生';
}
}
</script>
『捌』 javascript 單選框性別必須選擇,否則彈出消息 ("性別必須選擇!"); 謝謝!
if(radio[i].checked==ture){ ture 改成 true 你只是寫反了一個字母。
『玖』 關於JavaScript中表單性別按鈕驗證的問題
可以使用Jquery的is()方法更輕松的解決這個問題。
is() 根據選擇器、元素或 jQuery 對象來檢測匹配元素集合,如果這些元素中至少有一個元素匹配給定的參數,則返回 true。
<formaction=""method="post"onsubmit="returnyanzheng()">
性別:<inputtype="radio"name="sex"value="男"/>男<inputtype="radio"name="sex"value="女"/>女
<inputtype="submit"value="提交"/>
</form>
<script>
functionyanzheng(){//當表單提交時觸發的驗證方法
if(!$("input[name='sex']").is(":checked")){//如果name為sex的input沒有被選中
alert('未選中');//彈出提示
returefalse;//返回假值表單不會提交
}else{
returntrue;//返回真值表單提交
}
}
</script>
『拾』 js中 我要再頁面做一個雙擊顯示下拉菜單的功能 具體是在性別輸入欄 雙擊後 下拉出男女供選擇
幹嘛用雙擊呢?不累嗎?用單擊不是更好?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>無標題文檔</title>
<style type="text/css">
<!--
#x{width: 69px;padding: 6px;border: 1px solid #000000;position: absolute;left: 11px;top: 40px;display: none;}
#x a{display: block;line-height: 25px;color: #000000;text-decoration: none; font-size:12px;}
#x a:hover{color: #FFFFFF;text-decoration: underline;background-color: #000000;font-weight: bold; font-size:12px;}
-->
</style>
<script language="JavaScript">
<!--
var pos=function(str){
var Left=0,Top=0;
do{Left+=str.offsetLeft,Top+=str.offsetTop;}
while(str=str.offsetParent);
return {"Left":Left,"Top":Top};
}
function abc(str){
with(pos(str)){
document.getElementById('x').style.top=Top+22;
document.getElementById('x').style.left=Left;
}}
//-->
</script>
</head>
<body>
<input name="xingbie" type="text" id="xingbie" size="10" onclick="document.getElementById('x').style.display='inline';abc(this);">
<div id="x">
<a href="JavaScript:" onclick="document.getElementById('xingbie').value=this.innerText;document.getElementById('x').style.display='none';">男</a>
<a id="x2" href="JavaScript:" onclick="document.getElementById('xingbie').value=this.innerText;document.getElementById('x').style.display='none';">女</a></div>
</body>
</html>