js+jquery做调查问卷:每个题有四个选项,每个选项后面都有一个输入框

但是只有选项被选中的时候输入框才能出现,没有选中的选项输入框是隐藏的,怎么做求指教。第二个问题,在提交整个问卷的时候怎么把问卷的信息和被选中的信息传给后台,希望能写出代码... 但是只有选项被选中的时候输入框才能出现,没有选中的选项输入框是隐藏的,怎么做求指教。第二个问题,在提交整个问卷的时候怎么把问卷的信息和被选中的信息传给后台,希望能写出代码,外加解释!求大神解决!高分。。。。。如果回答的好,再追加100分
希望 给答案的大神 自己先测试一下能不能实现 先谢谢了!
展开
百度网友818239c
2013-05-31 · TA获得超过361个赞
知道小有建树答主
回答量:731
采纳率:25%
帮助的人:213万
展开全部
<!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 runat="server">
<title></title>

<style>
.com_div{ width:100%; float:left;}
.com_content{ width:1000px; margin:0px auto;}
.com1{ width:100%; float:left; margin-bottom:10px;}
.fleft{ float:left; margin-right:50px;}
.fleft1{ float:left; display:none;}
.fleft1 input{ border:1px solid #dddddd;}
</style>
<script src="../map_dialog/js/jquery.js" type="text/javascript"></script>
<script>
$(function () {
$(".com1 input:radio").click(function () {
var o = $(this).attr("checked") == "checked" ? true : false;
if (o) {
$(".fleft1").show();
}
});

});
</script>
</head>
<body>
<form id="form1" runat="server" action="test.aspx?action=save">
<div class="com_div">
<div class="com_content">
<div class="com1">1、1+1=?</div>
<div class="com1"><span class="fleft">A、1 <input type="radio" id="txta" name="txtanswer" value="1" /></span>
<span class="fleft">B、2 <input type="radio" id="txtb" name="txtanswer" value="2" /></span>
<span class="fleft">C、3 <input type="radio" id="txtc" name="txtanswer" value="3" /></span>
<span class="fleft">D、4 <input type="radio" id="txtd" name="txtanswer" value="4" /></span>
<span class="fleft1"><input type="text" id="other_txt" name="other_txt" /></span>

</div>
<div class="com1"><input type="submit" value=" 提 交" /></div>
</div>
</div>
</form>
</body>
</html>
//-------------------------------------------------------------------------
//后台代码
//-------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebTest.baidu_test
{
public partial class test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(Request["action"]!=null)
{
GetData();
}
}
/// <summary>
/// 得到数据
/// </summary>
public void GetData()
{
//得到前台选择的答案
string txt_answer = Request["txtanswer"].ToString();
}
}
}

//-你看这种可以不,如果不行可以跟我留言,希望能帮上你。
更多追问追答
追问
这个 我试了  不能实现  ,因为你的的便签里没有checked属性  你再方法里怎么判定真假  走到那就报错了。。。。 提交的方法  我要的是js方法  就是能把页面上已经选中的答案  的选项传给后台。。。希望能得到帮助
追答
你的aspx程序吗?你引用了jquery插件了吗?
戢运0s
2013-05-31 · 超过13用户采纳过TA的回答
知道答主
回答量:50
采纳率:0%
帮助的人:37.5万
展开全部
第一个问题:
<input type="radio" name="survey_ms_time" id="survey_ms_time" value="7:00" onclick="hide_other(this)"/>7:00
<input type="radio" name="survey_ms_time" id="survey_ms_time" value="7:15" onclick="hide_other(this)"/>7:15
<input type="radio" name="survey_ms_time" id="survey_ms_time" value="7:30" onclick="hide_other(this)"/>7:30
<input type="radio" name="survey_ms_time" id="survey_ms_time" value="" onclick="show_other(this)"/>{$lang.survey_other} <input id="survey_ms_time_other" name="survey_ms_time_other" type="text" style="display:none;"/>

function show_other(obj){
var id = obj.id;
var other = document.getElementById(id+"_other");
other.style.display = "";
}

function hide_other(obj){
var id = obj.id;
var other = document.getElementById(id+"_other");
other.style.display = "none";
}

第二个问题:
var obj = document.getElementsByTagName("input");
for (var m=0; m<obj.length; m++){
if (obj[m].type=="radio")
if(obj[m].checked) menuids += obj[m].value + ",";
}
document.getElementById("menuid").value = menuids;
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式