无法将textarea输入传递给PHP变量

时间:2013-07-22 23:28:13

标签: php javascript html textarea

首先,我正在使用3种语言。 HTML,Javascript和PHP。我无法将用户输入的textarea文本传递给PHP变量,该变量将用作将要发送的电子邮件中的消息。我认为问题在于我的textarea实际上是在一个模态窗口中,出于某种原因,我认为这就是搞砸了。

这是我的HTML代码:     

<form name="rejectForm" action="">

<div class="rejectModal" title="rejectModal" id="rejectModal" style="display: none; padding:15px ">     

    <b> Text in the modal window</b>
    <center>             
    <textarea id="rejectArea" name="rejectArea" value="{$rejectAreaNote}" rows="6" cols="43"/>    </textarea> 
    </center>
<br/>
<center>

    <input type="button" value="Reject" class="btn success id="submitReject""     id="btnRejectDocumentModal" name="Reject" />    

    <input class="btn" type="reset" value="Cancel" id="btnCancelSaveModal"  />
</center><br/><br/>
</div>
</form>
</div>

JS代码:

$(function() {  
$(".submitReject").click(function() {  
    // validate and process form here  
    $('.error').hide();  
  var rejectAreaNote = $("textarea#rejectArea").val();  
      var noteLength = rejectAreaNote.length;
            if (rejectAreaNote == "" || noteLength < 5) {  
                $("label#rejectArea_error").show();  
                $("textarea#rejectArea").focus();  
    return false;  
}  
var dataString = rejectAreaNote;  
alert (dataString);return false;  
$.ajax({  
    type: "POST",  
    url: "gs_ViewDocument.php",  
    data: dataString,  
    success: function() {  
        $('#reject_form').html("<div id='message'></div>");  
        $('#message').html("Reject Form Submitted!");
        }  
    });  
    return false;  
   });  
 });  

什么创造了Modal(JS):

    $('.rejectModal').css("background", "lightblue");
        $('#btnRejectDocument').bind(isTouchScreen ? "touchstart" : "click", function(){
       if (!gsSelection.unselectElem()) return false; 
           $('.rejectModal').dialog({
           modal:true, 
           resizable:false,
       width: 400,
   }).removeClass("ui-widget-content");
   $(".ui-dialog-titlebar").hide();
   return;
});
$('#btnRejectDocumentModal').bind(isTouchScreen ? "touchstart" : "click", function(){
   $(this).parents('div.rejectModal').dialog('close');
});
$('#btnCancelSaveModal').bind(isTouchScreen ? "touchstart" : "click", function(){
   $(this).parents('div.rejectModal').dialog('close');
});

PHP代码:

if(isset($_POST['Reject'])&&$_POST['Reject']=='Reject') 
{
    $isReject = true;
    RejectAction($DocumentID, $ClientName, $ClientEmail);
    $smartyvalues["isReject"] = $isReject;
    $smartyvalues["RejectMsg"] = "The document invitation was successfully rejected!";
}

非常感谢任何帮助。

2 个答案:

答案 0 :(得分:1)

尝试以下是应该修复它:

 <textarea id="rejectArea" name="rejectArea"  rows="6" cols="43"> {$rejectAreaNote}</textarea>

您关闭textarea代码两次/>然后</textarea>

答案 1 :(得分:0)

<input type="button" value="Reject" class="btn success id="submitReject""     id="btnRejectDocumentModal" name="Reject" />

这里的结束引号是错误的(在submitReject之后有两个引号)。