homepage Welcome to WebmasterWorld Guest from 184.73.52.98
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Please help -- Submitting forms, javascript
Submitting two diff. forms
mshahMCS




msg:1473029
 8:33 pm on May 1, 2003 (gmt 0)

I have a form, and I want two things to happen, depending on which submit button the user clicks.

If they click on the first submit button, I want another window to open, and the request to be submitted.

If they click on the second submit button, I want another window to open, the request to be submitted, and then the user to be redirected to a different page.

FOr example: I am working in document main.htm. popup.htm pops up, the request is submitted, and then main.htm is redirected to main2.htm.

So far the first part works, I use this

<form name="acctForm" method="post" action="popup.htm" target="_new">

And the new window pops up and the submit goes perfectly.

However, the second part, I cannot seem to reditrect the main page after the request is submitted. It gives me a javascript error when I try to do something like this:

<INPUT TYPE="submit" VALUE="Submit & Redirect" onClick="javascript:window.location("main2.html")>

Please help. It says action is not supported.

 

HocusPocus




msg:1473030
 11:39 pm on May 1, 2003 (gmt 0)

I would suggest the error is caused by
onClick="javascript:window.location("main2.html")>

try
onClick="javascript:location.href='main2.html';">
instead.

I don't think it's a good idea to have two submit buttons on one form. Hopefully someone will come along and explain why and help you out. Way past my bed time.

Hope you sort it.

ShawnR




msg:1473031
 7:07 am on May 2, 2003 (gmt 0)

"...I don't think it's a good idea to have two submit buttons on one form. Hopefully someone will come along and explain why and help you out. Way past my bed time...."

Now you've got me curious. So if no-one does come along and explain why while you are asleep, could you please explain in your morning

Thanks
Shawn

HocusPocus




msg:1473032
 8:11 am on May 2, 2003 (gmt 0)

Having slept on it, :) I realise that this is total rubbish. Even a well-known search engine uses 2 submits and a server side to workout which one is pressed.

My tired thoughts where that with mshahMCS page with 2 submit buttons to one form, and the sole use of JavaScripting to sort out what happens on submission was not the best approach. If you get 100,000 uniques a month and 8% have non scripting enabled browsers thatís... erm... possibly 8000 bad experiences on your web site per month.

People expect one send button, two buttons could confuse. I would have thought a better solution is to design the form so that thereís no need for more than one submit and use server side script to action.

Maybe I should have said
...I don't think it's a good idea to have two submit buttons on one form and only use Client side scripts to sort out the behaviours

I stand corrected, though I think I might go back to bed..

mshahMCS




msg:1473033
 12:12 pm on May 2, 2003 (gmt 0)

Thank you very much, it works perfectly.

THis is an internal site, so there is only a certain way everythign is configured, so I dont think it would be a problem.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved