当我尝试发布这个textarea时,它什么也没发送,显然没有返回该字段。
所有其他输入字段都可以。
我已经阅读过并且每个人都说要确保.value是在getelementid之后添加的,无论如何我都在做,所以我不确定是什么问题。
我正在使用Bootstrap 3,以防万一。
更新:我刚刚在textarea字段中进行了测试和硬编码的文本。那顺利通过了。但是我在表单中键入的任何文本都不会被传递。我想这可能是一个Bootstrap 3错误。
还有其他人知道吗?
使用Javascript:
var http_request = false;
function show_hint(p_hint_text, p_span) {
document.getElementById(p_span).innerHTML = p_hint_text;
}
function makePOSTRequest(url, parameters, SpanName) {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Cannot create XMLHTTP instance');
return false;
}
http_request.onreadystatechange = function () {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
//alert(http_request.responseText);
result = http_request.responseText;
document.getElementById(SpanName).innerHTML = result;
document.getElementById(StatusName).innerHTML = 'Ready';
} else {
alert('There was a problem with the request.');
}
}
};
http_request.open('POST', url, true);
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
alert(parameters);
http_request.send(parameters);
}
function Contact(obj, SpanName, StatusName) {
var curDateTime = new Date(); //For IE
var poststr = "gid=" + encodeURI(document.getElementById("gid").value) +
"&tid=" + encodeURI(document.getElementById("tid").value) +
"&cid=" + encodeURI(document.getElementById("cid").value) +
"&recid=" + encodeURI(document.getElementById("recid").value) +
"&item_ip=" + encodeURI(document.getElementById("item_ip").value) +
"&item_userid=" + encodeURI(document.getElementById("item_userid").value) +
"&item_author=" + encodeURI(document.getElementById("item_author").value) +
"&fromajax=" + encodeURI(document.getElementById("fromajax").value) +
"&action=" + encodeURI(document.getElementById("action").value) +
"&active=" + encodeURI(document.getElementById("active").value) +
"&message=" + encodeURI(document.getElementById("message").value);
var SpanName = SpanName;
var StatusName = StatusName;
//alert (SpanName);
alert(poststr);
makePOSTRequest('http://fakedomain.com', poststr, SpanName);
}
HTML
<span id="ContactFormSpanQXBIAHOBEU25">
<span id="statusQXBIAHOBEU25">
<form role="form" action="javascript:Contact(document.getElementById('ContactForm'),'ContactFormSpanQXBIAHOBEU25','statusQXBIAHOBEU25'); show_hint('Sending Data, Please Wait...', 'statusQXBIAHOBEU25');" method="post" name="ContactForm" id="ContactForm">
<input name="gid" id="gid" type="hidden" value="SDZOAYLTDV26">
<input name="tid" id="tid" type="hidden" value="ZBSAGNSCFM55">
<input name="cid" id="cid" type="hidden" value="2">
<input name="recid" id="recid" type="hidden" value="QXBIAHOBEU25">
<input name="item_IP" id="item_ip" type="hidden" value="555.555.555.555">
<input name="item_userid" id="item_userid" type="hidden" value="YCGLNBFZPD13">
<input name="item_author" id="item_author" type="hidden" value="YCGLNBFZPD13">
<input name="fromajax" id="fromajax" type="hidden" value="1">
<input name="action" id="action" type="hidden" value="add">
<input name="active" id="active" type="hidden" value="1">
<div class="form-group">
<textarea class="form-control" name="message" id="message" rows="5"></textarea>
</div>
<input name="Submit2" type="submit" class="btn btn-success btn-flat" value="Submit" />
</form>
</span>
</span>