Validation for drop down menus

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smartic
    New Member
    • May 2007
    • 150

    Validation for drop down menus

    I'm having more than one drop down menu i want to secure them all from unvalid data ex:

    [HTML]<select name="Category" size="5" id="Category">
    <option>Compute rs &amp; Networking</option>
    <option>Camer as &amp; Photo</option>
    <option>Consume r Electronics</option>
    <option>Jewel ry &amp; Watches</option>
    <option>Real Estate</option>
    </select>
    <select name="anotheron e" size="5">
    <option>Compute rs &amp; Networking</option>
    <option>Camer as &amp; Photo</option>
    <option>Consume r Electronics</option>
    <option>Jewel ry &amp; Watches</option>
    <option>Real Estate</option>
    </select>[/HTML]

    if i choose from one of these options give another select tag have many other options etc... , how can i secure them all by simple PHP code.
  • MarkoKlacar
    Recognized Expert Contributor
    • Aug 2007
    • 296

    #2
    Hi,

    be a bit more specific, do you have an example of what you want to happend?
    It maybe a webpage, imagage etc.

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      I also fail to comprehend what your problem is. As I see it now is that, when a value from a dropdown box is selected, a new dropdown box is shown with content depending on the selected value of the first dd box, right?

      Ronald

      Comment

      • smartic
        New Member
        • May 2007
        • 150

        #4
        yes (ronverdonk) that's what i mean how can i secure all this lists from any different values.

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          Best way to go about this is using plain JavaScript (when all values for all boxes are in the JS client code) or Ajax (a combination of JavaScript and PHP), used when all the values for the boxes is at the server.

          In the first case you go to your JS routine when an item in a box is selected and generate - via the DOM - a new dropdown box, filled with values from within JS.

          In the second, you go to a JS routine when an item in a box is selected, and pass that value to a PHP script at the server. The server script then fills a data stream with server values and sends it back to JS, who constructs a new dropdown box and fills it with the values received from the server script. See also this post in the forum.

          Ronald

          Comment

          • smartic
            New Member
            • May 2007
            • 150

            #6
            Thank you, but I'm using Ajax with PHP file that have XML header to populate the lists then when i choose from one of the lists populate another list etc from PHP file how can i read from the PHP file the XML tags and attributes within it using PHP Code to check for the values he choose.
            EX: (PHP FILE THAT HAVE XML HEADER)

            [HTML]
            <?xml version=\"1.0\" encoding=\"utf-8\"?>
            <Computers>
            <Menu type='Apple, Macintosh Computers'>
            <subMenu>Appl e Components</subMenu>
            <subMenu>Appl e Desktops</subMenu>
            <subMenu>Appl e Drives, Media</subMenu>
            <subMenu>Appl e Input Devices</subMenu>
            </Menu>
            </Computers>
            [/HTML]

            i need to check i he choose menu for (apple category) check the sub menu values etc.

            Comment

            • robin1983
              New Member
              • Oct 2007
              • 99

              #7
              ok i m posting the whole code to make clear bit a little lengthy ok
              Originally posted by MarkoKlacar
              Hi,

              be a bit more specific, do you have an example of what you want to happend?
              It maybe a webpage, imagage etc.

              Comment

              Working...