PDA

View Full Version : Get value from javascript dialog??


mattboy_slim
12-30-2002, 10:03 PM
Here is my dillemma:
----------------------
Link:
http://www.lakesnewsshopper.com/submit2.asp
----------------------
I have a rather complicated form, in which a user enters a classified ad into a text box, which then calculates the cost of that ad and displays it in a javascript dialog box. This form then sends the same email to both the end-user, and the site administrator. The email contains the form values, and is sent via CDONTS. My issue comes because I'd like to include the cost of the ad in the email, but I'm not sure how to state what that value is in an "ASP way".

---------------------
Link again:
http://www.lakesnewsshopper.com/submit2.asp
---------------------

If you have any ideas and/or suggestions, please let me know.

Thanks,
Matt

Code is attached in a .txt file also

whammy
12-30-2002, 11:44 PM
The easiest way is to have a hidden form field named "amount" or something like that (in the form that calculates the cost):

<input name="amount" type="hidden" value="" />

Which, by the way, is already present in your form. Also, it looks like this was accounted for in the javascript function formatCurrency() as well, just uncomment this line:

//document.form1.amount.value=formatCurrency(totalCost);

That will update the value of that hidden field to the cost, then you can retrieve the value using ASP once the form is submitted to the server:

Dim amount
amount = Request.Form("amount")

Of course, then you can use that variable in the CDONTS email, etc...:

"Weeks To Run Ad: "&request.form("Weeks_To_Run") & chr(13) &_
"Date To Start Ad: "&request.form("Date_Start") & chr(13) &_
"Cost: "&request.form("amount")

Hope this helps. ;)

mattboy_slim
12-31-2002, 03:07 PM
Well thanks Whammy. I forgot I had originally had the amount displayed in a text box. It works now...all well and dandy even.

Thanks for the help, and thanks to the forum overall for being awesome in my short time here.

whammy
12-31-2002, 11:03 PM
You're welcome! Stick around, this is one place you never stop learning! :)