求教高手:单选框选中相应的选项时弹出相应的文本框怎么实现哈

lukylfm 2010-06-01 05:57:01
想用单选框
实现在选中哪项时出现相应的文本框,不选时就隐藏看不到
具体怎么实现哈
谢谢各位
...全文
262 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
root_lee 2010-06-02
  • 打赏
  • 举报
回复
<!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=utf-8" />
<title>无标题文档</title>
</head>

<body>
<form name="form1" action="test.php" method="post" >
<div style="width:auto;height:30px;">
<div style="width:120px;height:30px;float:left;">是否要截取链接</div>
<div style="width:auto;float:left;"><input type="radio" name="sub" value="1" id="sub" onClick="changeType(true);"></div>
<div style="width:auto;float:left;">截取</div>
<div style="width:auto;float:left"><input type="text" name="sub1" id="sub1" style="display:none;"/></div>
<div style="width:auto;float:left;margin-left:10px;display:inline;"><input type="radio" name="sub" value="2" onClick="changeType(false);"/>不截取</div>
<div style="widows:auto;float:left;margin-left:10px;display:inline;"><input type="submit" /></div>
</div>
</form>
<script type="text/javascript">
function changeType(jiequ)
{
var objSub=document.getElementById("sub");
var objSub1=document.getElementById("sub1");
if(jiequ)
{
objSub.style.display="none";
objSub1.style.display="block";
}
else
{
objSub.style.display="block";
objSub1.style.display="none";
}
}
</script>
</body>
</html>
lukylfm 2010-06-02
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 root_lee 的回复:]
<!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="Conten……
[/Quote]

嗯哪,就是这个样子的,
可怎么调格式呢,能在选择之后,单选框还是在同一行么
root_lee 2010-06-02
  • 打赏
  • 举报
回复
<!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=utf-8" />
<title>无标题文档</title>
</head>

<body>
<form name="form1" action="test.php" method="post" >
<tr>
<td>是否要截取链接</td>
<td><input type="radio" name="sub" value="1" id="sub" onClick="changeType(true);">截取<input type="text" name="sub1" id="sub1" style="display:none;"/></td>

<td><input type="radio" name="sub" value="2" onClick="changeType(false);"/>不截取</td>

</tr>
<input type="submit" />
</form>
<script type="text/javascript">
function changeType(jiequ)
{
var objSub=document.getElementById("sub");
var objSub1=document.getElementById("sub1");
if(jiequ)
{
objSub.style.display="none";
objSub1.style.display="block";
}
else
{
objSub.style.display="block";
objSub1.style.display="none";
}
}
</script>
</body>
</html>
lukylfm 2010-06-02
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 lixiccgccyuan 的回复:]
引用 7 楼 lixiccgccyuan 的回复:
$("radio").click(function() {
$("#sub").toggle();--- 输入截取规则<input typy="text" name="sub" id="sub" style="display:none"/>

})

就不用JS写了啊,JS比较麻烦

<td><input type="radio"……
[/Quote]

试了,不行啊
lixiccgccyuan 2010-06-01
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 lixiccgccyuan 的回复:]
$("radio").click(function() {
$("#sub").toggle();--- 输入截取规则<input typy="text" name="sub" id="sub" style="display:none"/>

})

就不用JS写了啊,JS比较麻烦
[/Quote]
<td><input type="radio" name="sub" value="1" id="jiequ">截取</td>

$("#jiequ").click(function() {
$("#sub").toggle();--- 输入截取规则<input typy="text" name="sub" id="sub" style="display:none"/>

})
没实验,应该是好使的

<td><input type="radio" name="sub" value="2" />不截取</td>





lixiccgccyuan 2010-06-01
  • 打赏
  • 举报
回复
$("radio").click(function() {
$("#sub").toggle();--- 输入截取规则<input typy="text" name="sub" id="sub" style="display:none"/>

})

就不用JS写了啊,JS比较麻烦
leemiki 2010-06-01
  • 打赏
  • 举报
回复
逛逛,O(∩_∩)O哈哈~
lukylfm 2010-06-01
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 soldierluo 的回复:]
$("#radio").change(function(){
$("input[type=text]").hide();
$("#txt").show();
});
[/Quote]

没看明白呵
lukylfm 2010-06-01
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 lihui_shine 的回复:]
HTML code
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>test</title>
<script>
function c(o){
if(o.checked){
var on = o.nextSibling;
……
[/Quote]

跟我想要的不太一样
具体说一下

<form name="form1" action="test.php" method="post" >
<tr>
<td>是否要截取链接</td>
<td><input type="radio" name="sub" value="1">截取</td>

<td><input type="radio" name="sub" value="2" />不截取</td>

</tr>
<input type="submit" />


我想当选则截取时,出现文本框

输入截取规则<input typy="text" name="sub"/>


而且我想接收这个截取规则的值

浪尖赏花 2010-06-01
  • 打赏
  • 举报
回复
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>test</title>
<script>
function c(o){
if(o.checked){
var on = o.nextSibling;
if(on.style.display!='none'){
return;
}else{
on.style.display = "inline";
var os = document.getElementsByName(o.name);
for(var i=0;i<os.length;i++){
if(os[i]!=o){
on = os[i].nextSibling;
on.style.display = "none";
}
}
}
}
}
</script>
</head>

<body>
<input type="radio" name="r1" onclick="c(this)" value="1" checked><span>1</span>
<input type="radio" name="r1" onclick="c(this)" value="2"><span style="display:none">2</span>
<input type="radio" name="r1" onclick="c(this)" value="3"><span style="display:none">3</span>
<input type="radio" name="r1" onclick="c(this)" value="4"><span style="display:none">4</span>
<input type="radio" name="r1" onclick="c(this)" value="5"><span style="display:none">5</span>
<br>
<input type="radio" name="r2" onclick="c(this)" value="1" checked><span>一</span>
<input type="radio" name="r2" onclick="c(this)" value="2"><span style="display:none">二</span>
<input type="radio" name="r2" onclick="c(this)" value="3"><span style="display:none">三</span>
<input type="radio" name="r2" onclick="c(this)" value="4"><span style="display:none">四</span>
<input type="radio" name="r2" onclick="c(this)" value="5"><span style="display:none">五</span>
</body>

</html>
soldierluo 2010-06-01
  • 打赏
  • 举报
回复
$("#radio").change(function(){
$("input[type=text]").hide();
$("#txt").show();
});
lukylfm 2010-06-01
  • 打赏
  • 举报
回复
各位大侠帮帮忙

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧