如何从使用数据库行作为id的textarea获取值和id

时间:2013-09-19 11:28:02

标签: javascript html pdo get textarea

这是我想要的response14.php?questionID=1&question=yes&approved=1

以下是我目前获得的response14.php?questionID=[object%20Object]&question=undefined&approved=1

这是js文件:

$(document).ready(function(){
    $(".save_btn").on('click', function() {
         var check = $("input[name=no]").is(":checked")?2:1;
         var questionID = $("textarea[id=questionID]").val();
         var question = $("textarea[value=question]").val();
        location = "response14.php?questionID=" +questionID + "&question=" +question + "&approved=" +check;

这是渲染的html:

 <td style='border:1px white; padding: 5; margin: 5;'><div id='wrap'>
<textarea cols='85' rows='2' id='3792' class='response textbox'>Hello C!!

Where can I send you fan mail? :)
I want your autograph and I'm from the Philippines :)

God bless Cooper!</textarea>
    YES: <input type='checkbox' name='yes' value='yes'> &nbsp;&nbsp;&nbsp;
    NO: <input type='checkbox' name='no' value='no'>    </div></td></tr><tr style='border:1px white; background-color:lightgrey; color:black; padding: 5; margin: 5;'><td style='border:1px white; vertical-align:top; padding: 5; margin: 5;'>Gavin Casalegno</td>
                      <td style='border:1px white; padding: 5; margin: 5;'><div id='wrap'>
<textarea cols='85' rows='2' id='3793' class='response textbox'>What is your religion?
Do you believe in God?
How much you measure height?</textarea>
    YES: <input type='checkbox' name='yes' value='yes'> &nbsp;&nbsp;&nbsp;
    NO: <input type='checkbox' name='no' value='no'>    </div></td></tr></tbody></table><button type='button' class='save_btn' style='align:right'>Save All</button><br>

关于如何解决这个问题的任何想法???

1 个答案:

答案 0 :(得分:1)

尝试替换

var questionID = $("textarea[id=questionID]").val();
var question = $("textarea[value=question]").val();

var questionID = $(textarea).attr('id');
var question = $(textarea).val();