Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to delegate a form's submit to a new window to be opened? 1

Status
Not open for further replies.

khashyar7

Technical User
Aug 11, 2004
69
0
0
CA
Hi,

I have a form that is invoking the submit in an ASP after a whole bunch of data gatherings and calculations and shows the results in the same form that it loads up.

I was wondering how could I delegate this submit function to a new window to be opened?
should I use inheritence or something?

Thanks,

Kash
 
It's simple - just add a target line to your form:
Code:
<body>
<form method="post" id="frm" [!]target="_new"[/!]>
<input type="submit" value="click me" />
</form>
</body>

-kaht

How much you wanna make a bet I can throw a football over them mountains?
sheepico.jpg
 
Thanks a lot ! It worked fine, but I think it would be preferable if the window that pops up had a smaller size so would be tangible for the user that another window just opened and the first one's still there !

IS there an easy way to do that too?

Thanks,

Kash
 
ok this is what I have now:

<FORM NAME="QUICKRATE_FORM" ID="QUICKRATE_FORM" ACTION=" METHOD="POST" target="myNewWin" onsubmit="window.open('', 'myNewWin', 'width=200,height=100');"><INPUT TYPE="HIDDEN" NAME="SHIPACTION" VALUE="QuickRate"><INPUT TYPE="HIDDEN" NAME="QR_DESTINATION" VALUE="WORLD"><INPUT TYPE="HIDDEN" NAME="DESTINATION" VALUE=""><INPUT TYPE="HIDDEN" NAME="PACKAGEDESC" VALUE=""><INPUT TYPE="HIDDEN" NAME="TOPROVINCEDESC" VALUE=""><INPUT TYPE="HIDDEN" NAME="TOCOUNTRYDESC" VALUE=""><TABLE BORDER=0 CLASS='TABLEOUTSIDE' BORDER=0 WIDTH="776" CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN='LEFT'><BR></TD></TR>

It's still the same as before. The new size is not taking effect.

Any suggestions?

Thanks,

Kash
 
any ideas ?

I really need to get this to work !

Thanks,

Kash
 
any ideas ?

Yes - how about getting your source code to validate first. You have no closing table tag, and no closing for tag. You also have no open or closing html or body tags.

If I fill in those missing elements, and add a "submit" button to test it with, it works just fine for me in IE and Fx.

If you are calling the "submit" method of the form programatically, then it will never work, as that bypasses the onsubmit handler.

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Dan,

I wish I could attach the file here, so you could see for yourself. The closing tags and everything are present in the file. I only wrote the opening tag here, since I thought that is the only thing to be modified in order for the whole thing to work.

Anyhow, I believe your last point is refering exactly to the issue here:

I have a function:

function clickSubmit()

that gets called when clicked on a button and that after a whole bunch of validation on the values inputed in the form calls:

myFormObj = getFieldObject("", "QUICKRATE_FORM", "");
myFormObj.submit();

as you pointed out, the latter call probably overrides the onSubmit, but I don't know how else I could have this called in the clickSubmit() function.
I tried commenting out "myFormObj.submit()" but like I was expecting nothing happened when clicked on the button.

Thanks,

Kash
 
Knowing that calling the submit method bypasses the onsubmit handler, why not simply move it, if the only way the form is submitted is programatically.

Remove the red bit from here:

Code:
<FORM NAME="QUICKRATE_FORM" ID="QUICKRATE_FORM" ACTION="[URL unfurl="true"]http://shipnow.purolator.com/ShipOnline/SecurePages/Payment/process_shipment.asp"[/URL] METHOD="POST" target="myNewWin" [!]onsubmit="window.open('', 'myNewWin', 'width=200,height=100');"[/!]>

and add these new red bits here:

Code:
myFormObj = getFieldObject("", "QUICKRATE_FORM", "");
[!]window.open('', 'myNewWin', 'width=200,height=100');[/!]
myFormObj.submit();

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
yooohooo ! It worked great :)

Thanks a lot !

Kash
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top