Welcome to WebmasterWorld Guest from 54.226.146.15

Forum Moderators: open

Message Too Old, No Replies

Please help -- Submitting forms, javascript

Submitting two diff. forms

     

mshahMCS

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

10+ Year Member



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

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

10+ Year Member



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

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

WebmasterWorld Senior Member 10+ Year Member



"...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

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

10+ Year Member



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

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

10+ Year Member



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.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month