display text field based on the selection choices

Discussion in 'ASP General' started by John Davis, Sep 16, 2003.

  1. John Davis

    John Davis Guest

    I want to display credit card fields when the user selects the option paid
    membership. If user selects the option free membership, then the credit card
    text field will disappear. Here's the code I did with JavaScript but didn't
    work.


    > <SCRIPT LANGUAGE="JavaScript">
    > function generateCreditTextField()
    > { if (document.myform.membership.value == "1")
    > { alert('free');
    > document.write("");
    > }
    > else
    > { alert('paid');
    > document.write("<P>Credit Card: <input type="text"

    name="credit")</P>");
    > }
    > }
    > </SCRIPT>
    >
    > <form name="myform">
    > <select name="membership" onchange="generateCreditTextField()">
    > <option></option>
    > <option value="1">Free Membership</option>
    > <option value="2">Paid Membership</option>
    > </select>
    > </form>
    >
    > please advise! Thanks!
    > John
    >
    >
     
    John Davis, Sep 16, 2003
    #1
    1. Advertising

  2. John Davis

    Adrienne Guest

    Gazing into my crystal ball I observed "John Davis"
    <> writing in
    news::

    > I want to display credit card fields when the user selects the option
    > paid membership. If user selects the option free membership, then the
    > credit card text field will disappear. Here's the code I did with
    > JavaScript but didn't work.
    >
    >
    >> <SCRIPT LANGUAGE="JavaScript">
    >> function generateCreditTextField()
    >> { if (document.myform.membership.value == "1")
    >> { alert('free'); document.write(""); } else
    >> { alert('paid');
    >> document.write("<P>Credit Card: <input type="text"
    >> name="credit")</P>"); } } </SCRIPT>
    >>
    >> <form name="myform">
    >> <select name="membership" onchange="generateCreditTextField()">
    >> <option></option>
    >> <option value="1">Free Membership</option>
    >> <option value="2">Paid Membership</option> </select> </form>
    >>
    >> please advise! Thanks!
    >> John
    >>
    >>

    >


    What about users without javascript?

    You could always do something put the option on page one, then test for the
    value of the option on the next page, and generate the credit card based on
    that.

    --
    Adrienne Boswell
    Please respond to the group so others can share
    http://www.arbpen.com
     
    Adrienne, Sep 16, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew Crowe
    Replies:
    1
    Views:
    4,558
    Andrew Crowe
    Sep 13, 2004
  2. Jerry Manner
    Replies:
    5
    Views:
    583
    Jonathan N. Little
    Jun 9, 2005
  3. Steve Speirs
    Replies:
    0
    Views:
    170
    Steve Speirs
    Jun 27, 2003
  4. Loebb
    Replies:
    0
    Views:
    222
    Loebb
    Feb 23, 2004
  5. Replies:
    13
    Views:
    283
    Dr John Stockton
    Jan 28, 2005
Loading...

Share This Page