Options in Drop down box

Discussion in 'HTML' started by Paul BRYAN, Dec 2, 2003.

  1. Paul BRYAN

    Paul BRYAN Guest

    Hi

    I'm using IE to create a form that includes a drop down box and a submit
    button .

    The drop down box contains a number of options, but one of the options is no
    longer available.

    If the unavailable option is chosen and the submit button is pressed, how do
    I get a pop up box to appear telling the user the option is no longer
    available.

    Hope this makes sense


    Paul
    Paul BRYAN, Dec 2, 2003
    #1
    1. Advertising

  2. Paul BRYAN

    brucie Guest

    in post <news:sSYyb.1390$>
    Paul BRYAN said:

    > If the unavailable option is chosen and the submit button is pressed, how do
    > I get a pop up box to appear telling the user the option is no longer
    > available.


    the only reliable way to do it would be to either remove the option
    server side so its not there to be selected or check if an option is no
    longer valid when the form is submitted and return an error message. you
    could use a bit of JS to pop up an alert but you'll still need to do the
    server side checking.

    --
    brucie
    02/December/2003 07:35:50 pm kilo
    brucie, Dec 2, 2003
    #2
    1. Advertising

  3. Paul BRYAN

    Steve R. Guest

    Paul BRYAN wrote in message ...
    > The drop down box contains a number of options, but one of the options is no
    > longer available.


    Surely the most "User-Friendly" action is to remove the option itself. LOL.

    Steve.
    Steve R., Dec 2, 2003
    #3
  4. Paul BRYAN

    Louis Somers Guest

    "Paul BRYAN" <> wrote in
    news:sSYyb.1390$:

    Like others say, best is to remove the option, but if you insist, here is
    some javascript that will alert the yser (but not prevent).

    <html><head>
    <script type="text/javascript" language="JavaScript">
    function CheckAvail(theForm)
    {
    var mytext = theForm.selection.value;
    if (mytext == 's002') {
    alert('potatoes have been sold out');
    theForm.thetext.focus();
    }
    }
    </script>
    <title>limit chars</title>
    </head>
    <body>
    <form method="post" action="yoururl" id="myForm">
    <select name="selection" onChange="CheckAvail(myForm);">
    <option value="s001">flowers
    <option value="s002">potatoes
    <option value="s003">cheese
    <option value="s004">beans
    </select>
    </form>
    </body></html>


    --
    News Updater, No scripts, No Database
    http://www.xmlssoftware.com/NUpdater
    Louis Somers, Dec 2, 2003
    #4
  5. Paul BRYAN

    Olaf Studt Guest

    Louis Somers wrote:
    >
    > Like others say, best is to remove the option, but if you insist, here is
    > some javascript that will alert the yser (but not prevent).
    > [...]
    > <form method="post" action="yoururl" id="myForm">
    > <select name="selection" onChange="CheckAvail(myForm);">
    > [options]
    > </select>
    > </form>


    Another possibility is

    <form ... onSubmit="return myFunc();">

    where, if myFunc returns false , the submission is
    cancelled - _*IF*_ the user has enabled JavaScript!

    --
    Olaf from THE Hamburg (not home of hamburgers)
    Replace laundry basket by my last name to avoid ending up in such.
    Olaf Studt, Dec 3, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SirPoonga
    Replies:
    2
    Views:
    738
    Ben Strackany
    Jan 7, 2005
  2. weiwei
    Replies:
    0
    Views:
    997
    weiwei
    Jan 5, 2007
  3. msimmons
    Replies:
    0
    Views:
    453
    msimmons
    Jul 16, 2009
  4. nagesh
    Replies:
    1
    Views:
    97
    Vladdy
    Apr 23, 2005
  5. Replies:
    3
    Views:
    277
    preet
    Aug 11, 2006
Loading...

Share This Page