dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: Selection alerts - please help!

Hybrid View

  1. #1
    Join Date
    Nov 2002
    Location
    UK
    Posts
    41

    Exclamation Selection alerts - please help!

    Is it possible to put an alert for each option in a selection.

    So, if i have the following selection item:

    <select name= "SelectionOne">
    <option value="1" >1</option>
    <option value="2" >2</option>
    <option value="3" >3</option>

    can I return an different alert for each option?

    TIA
    Tricky
    ____________________________
    Toon Toon Black and White Army



  2. #2
    Join Date
    Nov 2002
    Location
    England
    Posts
    275
    Somehthing like this may be what you want:

    Code:
    <script type="text/javascript"><!--
      function doAlert(optionValue) {
        switch(optionValue) {
          case "1":
            alert('Message 1');
            break;
          case "2":
            alert('Message 2');
            break;
          case "3":
            alert('Message 3');
            break;
        }
      }
    //--></script>
    <select name= "SelectionOne" onchange="doAlert(this.options[this.selectedIndex].value);">
      <option value="1" >1</option>
      <option value="2" >2</option>
      <option value="3" >3</option>

  3. #3
    Join Date
    Nov 2002
    Location
    UK
    Posts
    41
    Hi,

    Thanks for the help! However, I need to be able to pass the alert messages from parameters in the doAlert() call. Further more, it would not be possible for me to use this sort of function:

    doAlert('message1','message2',',message3')

    (There is a complicted reason for this due to the way my scripts are written from another program)

    I had thought something like this would be possible :

    <script language="JavaScript">
    function valSel(Name,Msg)
    {
    if (Name.options[0].selected)
    {alert(Msg);}
    //repeat for each line or perhaps do a loop [i]
    }
    </script>

    <select name= "SelectionOne">
    <option value="1" onSelect="return valSel(document.MyForm.SelectionOne,'Warning ONE')" >1</option>
    <option value="2" onSelect="return valSel(document.MyForm.SelectionOne,'Warning TWO')">2</option>
    <option value="3" onSelect="return valSel(document.MyForm.SelectionOne,'Warning THREE')">3</option>
    </select>

    What do you think?
    Tricky
    ____________________________
    Toon Toon Black and White Army



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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