Forum Moderators: open

Message Too Old, No Replies

prototype: Form.serial(formName) problems

Having problems getting the serialize funxtion working consistantly

         

dungareez

5:11 am on Jul 6, 2007 (gmt 0)

10+ Year Member



I am having an issue getting the prototype library Form.serialize function to work with one of my forms and I can't seem to figure out why.

I made the following function to serialize forms and add some other data to the post request..

function formSend(formName, sendData) {
sendData = sendData +"&"+ Form.serialize(formName);
//alert (sendData);
new Ajax.Request("centercontent.php", { method: 'post', postBody: sendData, onComplete: onFinish});
}

This is the form I am trying to submit (it is created somewhat dynamically with php, but I will include the clientside output (from firebug) for clarity

<form id="itemEntry">
<a href="#lowercenterAnchor">Item Name</a>
<input id="itemName" tabindex="1" size="25"/>
<br/>
Description:
<textarea id="description" tabindex="2" cols="50" rows="5">describe</textarea>
<br/>
Pack QTY:
<input id="packQty" tabindex="3" size="15"/>
Cost:
<input id="cost" tabindex="4" size="10"/>
<br/>
Web page Link:
<input id="link" tabindex="5" size="30"/>
<br/>
Keywords
<input id="keywords" tabindex="6" size="25"/>
<br/>
(Keywords will be used to search for an item, can be related to tests it used for etc. Separate by spaces
<br/>
Comments:
<textarea id="comments" tabindex="7" cols="50" rows="5">comments?</textarea>
<br/>
<input id="addItem" type="button" onclick="formSend('itemEntry','mode=6&add=yes&vendorID=9');" tabindex="8" value="Add Item!"/>
</form>

the data posted according to firebug is: mode=6&add=yes&vendorID=9&

my form data should be after the last & and is not. I use this same function other forms and it works fine. Any help would be greatly appreciated.

Thanks

vincevincevince

5:42 am on Jul 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<form id="itemEntry"> --> <form name="itemEntry"> ?

dungareez

2:39 pm on Jul 6, 2007 (gmt 0)

10+ Year Member



Thanks alot, it worked. Geez I hate to think how much time I wasted looking for that. I tried using the name = in the form tag before, but I had to add name = "elementNameHere" for all of the elements before they showed up. I thought the prototype serialize utlized the getElementById() funtionality and the name= would just be redundant when the id= was already there. Thanks so much.

Cheers.