SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Display message if certain value returned

    Hi guys

    I am looking to return a pop up box if a certain value from my select box is picked

    PHP Code:

                    
    var inpObjs document.getElementsByName('typeofbike[]');        
                
    validChars=/^[a-zA-Z\d]{16}$/;
                    for(
    i=0inpObjs.lengthi++){
                       if (
    typeofbike== 'I will be using my own bike')
                           
    alert("If using your own scooter / bike for training, it must be of a road worthy condition, to our instructors satisfaction. Please also bring with you your current CBT certificate, a valid certificate of insurance, MOT (if applicable), and also ensure the vehicle is displaying a valid tax disc and two legally sized L Plates");
                           return 
    false;
                        }
                    } 


    Could you guide me as to where I am going wrong


    Thanks in advance

    Chris

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2011
    Location
    Bs. As. - Argentina
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Question, did you actually get a collection when you do
    Code JavaScript:
    var inpObjs = document.getElementsByName('typeofbike[]')

    My question is, in the HTML code object should have the name typeofbike[] including the [] sings whitout numbers inside. I mean, it's strange. Can you post the HTML to see what we are tallking about?

    By the way, geting objects by name do not get you a colection of options that is probably what are you triyng to do casue you mentioned a "select" object.


    See you

  3. #3
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    Yes it is checking a array and not just a single value

    I hope this helps


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •