#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Form Validation (If & then)


    Hi guys, first i hope u will understand me...
    So i want to make a javascript to be shown if somebody chooses option A to show the javascripts for the A1,A2,A3 and if they choose B to show javascripts for the B1,B2,B3. So the A and B it will firstly asked as options from a <select> tag
    eg.
    Code:
    <select name="AorB" >
    <option value="" selected="selected">Select...</option>
    <option value="A" >Option A</option>
    <option value="B" >Option B</option>
    </select>
    I'm using this way of javascript (Error Alerts):

    Code:
    <SCRIPT language=JavaScript>
    <!--
    function check(form) {
    if (form.Password.value == "")
    { alert("Please enter your Password."); form.Password.focus(); return;}
    if (form.Password.value.length < 8)
    { alert("Please enter a valid Password."); form.Password.focus(); return;}
    form.submit()
    }
    //-->
    </SCRIPT>
    P.S: I don't want to make complications when they choose A to get B option javascripts or reverse.


    added: i mean if We select OPTION A there will be shown some Input-s ....and javascript will ask only for the shown input-s so it means OPTION A input-s ... but not to ask for OPTION B input-s too even that they're not shown cause we didnt select OPTION B ... i hope i explained a little for you.

    CHECK OUT THIS LINK PLEASE, explains how i really mean.
    http://misinba.altervista.org/form/
  2. #2
  3. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,007
    Rep Power
    2791
    Welcome to DevShed, closser.

    Originally Posted by closser
    added: i mean if We select OPTION A there will be shown some Input-s ....and javascript will ask only for the shown input-s so it means OPTION A input-s ... but not to ask for OPTION B input-s too even that they're not shown cause we didnt select OPTION B ... i hope i explained a little for you.
    Was that paragraph designed to cause a brain hemorrhage?

    Is this an accurate translation of your request?
    Code:
    if A then show A and B inputs
    if B then show B inputs
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0
    Originally Posted by Winters
    Welcome to DevShed, closser.

    Was that paragraph designed to cause a brain hemorrhage?

    Is this an accurate translation of your request?
    Code:
    if A then show A and B inputs
    if B then show B inputs
    No, in both of your questions , sir.
    I tried to translate & explain it ..anyway it's your right to ban me !
  6. #4
  7. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,007
    Rep Power
    2791
    I need you to explain, as though talking to a child, what you want the script to do.
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0
    fixed , close the thread thank you SMARTguay.

IMN logo majestic logo threadwatch logo seochat tools logo