reading individual form elements on a page - please help

P

pbd22

I need help understanding how to read multiple form elements on a
page
that one, individual "submit" button can send to their respective
action= tags.

So the "registration" page has, say 5 forms on it, each has its own
data that
has to be sent to the server (lets say, different server pages for
different types
of processing:

<form id=form1 action=page1.aspx method=post>
</form>
<form id=form2 action=page2.aspx method=post>
</form>
<form id=form3 action=page3.aspx method=post>
</form>
<form id=form4 action=page4.aspx method=post>
</form>
<form id=form5 action=page5.aspx method=post>
</form>


how should i construct this? I have a script for reading the
individual forms
on this page:

readforms = function (fromwhere){
var nestedForms = $(fromwhere).select('form');
var formElements = [];
for (var i = 0; i< nestedForms.length;i++) {
if (exist(nestedForms)) {
formElements.push(nestedForms.serialize());
}
}
alert(formElements.inspect());
}


and this is my submit tag:

<a href='#' onclick="readforms(this);"
class="textBtnRed"><span>Publish</span></a>

Could somebody explain to me how to use this code to "fire" each form
for processing on
the server? What I am working with is not changable - no input tags,
no runat=server no single
form tag. This is per the customer's request.

please help. thanks.
peter
 
J

Joost Diepenmaat

pbd22 said:
Could somebody explain to me how to use this code to "fire" each form
for processing on
the server? What I am working with is not changable - no input tags,
no runat=server no single
form tag. This is per the customer's request.

Your customer is making stupid requests.

Anyway, you can probably submit each form to a different (hidden)
iframe.
 
P

pbd22

i agree but that doesn't really help.
could you please explain or show me how this would be done.

thanks,
peter
 
J

Joost Diepenmaat

pbd22 said:
i agree but that doesn't really help.
could you please explain or show me how this would be done.

document.forms['form1'].submit();
document.forms['form2'].submit();
document.forms['form3'].submit();

etc.. you just have to make sure the form elements have a target
attribute pointing to some unique frame, since the default target will
overwrite the current page, probably preventing any subsequent script
actions:

<form name="form1" ... target="frame1"> ... </form>
<iframe name="frame1" ...>...</iframe>
<form name="form2 ... target="frame2"> ... </form>
<iframe name="frame2" ...>...</iframe>

etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top