Forum Moderators: open

Message Too Old, No Replies

is Javascript the best way to achieve this?

js newbie needs advice on form-related query

         

hoom

10:28 pm on Oct 7, 2009 (gmt 0)

10+ Year Member



Hi - I'm a complete newbie with javascript and am not even sure if this is the right method of achieving what I'm aiming to do. If another solution suggests itself I'd be more than happy to hear about it.
I have a booking form for a 3 linked conferences - the user selects whichever one (or ones) he/she wants to attend via 3 checkboxes; so far so straightforward, I've done loads of these before and use an HTML page holding the form to pass the form data through to an ASP page which then fires the data in an email to the conference organiser, finally redirecting to a "thank you" page.
What I'd like to do is have some way of triggering a message on-screen (not a pop-up window) depending on which checkbox or combination of checkboxes is selected, indicating the total cost and the discount available for booking more than one.
Say, for example:
You've booked one conference at £50
You've booked two conferences at £75 (a saving of £25)
You've booked all three conferences at £100 ( a saving of £50)

I'd assume that this is possible using javascript to trigger a hidden field for each of the above messages, but I appreciate that if javascript is turned off in the browser, that ain't going to work. So - is there another way of doing this?

If javascript is the best way, I'd really appreciate some pointers in how to get started with this. Thanks in advance for any assistance/advice.

rocknbil

7:06 pm on Oct 8, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard hoom, why can't you just do this in your ASP mailer script?

Many coders "redirect" to a thank you page, which IMO is a waste of resources and disables the ability to provide good response pages.

So your ASP mailer logic would be something like this:

- Accept and validate posted info
- If there are errors, output form directly from the script. Don't go back to the initial form, output a "copy" of the form so you can populate any submitted values.
- If no errors, send email.
- Output response page.

The output of the script can contain the verbiage you specify based on what is being input to the form.

So no, especially for the reason you mentioned, Javascript is not really needed here.

hoom

7:28 am on Oct 9, 2009 (gmt 0)

10+ Year Member



Thanks, I'd wondered whether I was complicating things a little there - the client wanted something which would trigger the message(s) depending on what was selected and as there's the possibility of someone checking box 1, box 1+box 2, box 1+box 3, box 2+box 3, or just box 2 or box 3, I assumed there'd need to be some javascript in there (if else, if else stuff)...
perhaps the answer is to keep it simple and just print the selections once the form is complete.