41 users online (0 members and 41 guests)  


  Results 1 to 6 of 6

Related

  1. Replies: 2
  2. Jump Menu covers drop down menu    Forum: HTML Forum
    Replies: 1
  3. Drop down menu    Forum: HTML Forum
    Replies: 6
  4. Replies: 6
  1. #1
    J-Man's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Nov 2003
    Posts
    32

    Validate Drop Down Menu

    How do you ensure that a selection was made from a Drop Down menu on an HTML form? I have no problem ensuring that text boxes are filled...but, I can't figure out how to test a Drop Down Menu. Thanks in advance!!!

  2. #2
    J-Man's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Nov 2003
    Posts
    32

    Validate Drop Down Menu & Table Cells

    Two questions:

    1) How can you ensure (validate) that a selection is made from a drop down menu on an HTML form? I don't have a problem ensuring that text boxes are filled, but I can't figure out how to check on Drop Down Menu Selection.

    2) I have a table on my HTML form. I have it set up that I click on one cell and another cell is filled with text. How can I ensure that all cells (that must be filled this way) are filled with text?

    Thanks in advance!!!!

  3. #3
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Hi there,

    Presumably, if your putting the contents of cells in other cells, you might be using the innerHTML property. If so, you can validate the innerHTMl of the cells that must be filled the same way you weould fill them.

    You can check the value of a dropdown using -

    Code:
    document.formname.inputname.options[document.formname.inputname.selectedIndex].value;
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  4. #4
    J-Man's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Nov 2003
    Posts
    32
    Quote Originally Posted by QuietDean
    Hi there,

    Presumably, if your putting the contents of cells in other cells, you might be using the innerHTML property. If so, you can validate the innerHTMl of the cells that must be filled the same way you weould fill them.
    DOH!!! You are totally correct with the innnerHTML comment! It's been awhile since I've looked at this code...and, apparently, I totally forgot how I was doing things. Thanks much!!!

  5. #5
    J-Man's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Nov 2003
    Posts
    32
    Quote Originally Posted by QuietDean
    Hi there,
    You can check the value of a dropdown using -
    Code:
    document.formname.inputname.options[document.formname.inputname.selectedIndex].value;
    I can't get this to work?!?!?!? Can you show me an example with actual names in place of formname and inputname? I think I'm missing something here. Thanks!

  6. #6
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Sure, heres a simple example.

    Its more portable, as it uses 'this', but the principle is the same. Its not validating as such, just alerting us to the values. Should be easily adaptible.

    HTML Code:
    <script language="JavaScript" type="text/javascript">
    function AlertValue(obj) {
    alert(obj.options[obj.selectedIndex].value);
    }
    </script>
    
    <form name="stoat">
    <select name="DropDownName" onChange="AlertValue(this);">
    <option value="Choose one of the others!">Choose an option...</option>
    <option value="First Option">First</option>
    <option value="Second Option">Second</option>
    <option value="Third Option">Third</option>
    </select>
    </form>
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?



Tags for this Thread