How to control the order in which forms are displayed

Discussion in 'Javascript' started by Supreme, Feb 17, 2004.

  1. Supreme

    Supreme Guest

    Hello! I am trying to structure the order of a series of forms that
    make up one record. Basically, I would like to detect the day of the
    week, and based on the day send the end user to a particular form,
    followed by another particular form, etc.,. The logic would be...

    form1 (submit)-> form2 (submit)-> form3 (submit)-> form4 (submit)->
    Thanks page
    else if(Tuesday || Thursday)
    form2 (submit)-> form4 (submit)-> Thanks page
    form1 (submit)-> form3 (submit)-> Thanks page

    Is javascript the best way to accomplish this? How? Any help is
    greatly appreciated. Thanks!
    Supreme, Feb 17, 2004
    1. Advertisements

  2. Client side javascript, no, server side javascript (most commonly
    server-side JScript in ASP), yes.

    To attempt this client-side would introduce a completely avoidable
    dependence on an optional technology and the results would be needlessly

    A server side script would be quite capable of writing the URL into the
    action attribute on whichever form it was outputting based on whatever
    criteria you chose. But exactly how would depend on your choice of
    server-side language/approach and would be off topic here. Unless the
    implementation was server-side javascript/JScript in which case you
    would probably want to use the date information available to create a -
    Date - object, where:-

    var dt - new Date();

    - would return the current date and time (on the server) as a Date
    object, and:-

    var weekDay = dt.getDay();

    - or -

    var weekDay = (new Date()).getDay();

    - would assign the current day of the week to the - weekDay - variable
    as a number in the range 0 to 6 where zero was Sunday. And then use that
    number as the basis for the decision.

    Richard Cornford, Feb 17, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.