Menu

#2 textarea contents not posted

closed
nobody
None
5
2005-10-16
2005-10-14
No

Form fields of type 'textarea' are not being posted by
AA.

After handling the case for the 'textarea' element type
in AjaxAnywhere.prototype.preparePostData(), things
work fine.

New code for the fix starts with >>> below.

AjaxAnywhere.prototype.preparePostData =
function(submitButton) {
var form = this.findForm();
var result = "";
for (var i = 0; i < form.elements.length; i++) {
var el = form.elements[i];
if (el.tagName.toLowerCase() == "select") {
for (var j = 0; j < el.options.length; j++) {
var op = el.options[j];
if (op.selected)
result += "&" + escape(el.name) +
"=" + escape(op.value);
}
} else if (el.tagName.toLowerCase() == "input") {
if (el.type.toLowerCase() == "checkbox" ||
el.type.toLowerCase() == "radio") {
if (el.checked)
result += "&" + escape(el.name) +
"=" + escape(el.value);
} else if (el.type.toLowerCase() ==
"submit" || el.type.toLowerCase() == "image") {
if (el == submitButton) // is "el" the
submit button that fired the form submit?
result += "&" + escape(el.name) +
"=" + escape(el.value);
} else if (el.type.toLowerCase() != "button") {
result += "&" + escape(el.name) + "=" +
escape(el.value);
}
}
>>> else if (el.tagName.toLowerCase() == "textarea") {
>>> result += "&" + el.name + "=" + escape(el.value);
>>> }

}
return result;
}

PS: The code indentations in aa.js is not very
readable. The following is a good free javascript code
formatter which I use :
http://www.jcay.com/javascript-code-improver.html

Discussion

  • Anonymous

    Anonymous - 2005-10-14

    Logged In: YES
    user_id=878510

    Ignore the comment about code indentation. The formatting of
    aa.js in the latest CVS version is good.

     
  • Nobody/Anonymous

    Logged In: NO

    Ok for the fix, however, I's better to do escape(el.name)

    PS. JS code formating is done by IntelliJ. I find if important to
    follow the main formaing for JS and Java code within the same
    project.

     
  • Vitaliy Shevchuk

    • status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB