drop down menu returning 0 value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MickG

    #1

    drop down menu returning 0 value

    Hi,

    I want my drop down box to be able to return wrap =0. It works fine
    with 2.95 and 3.95 but does bot return a 0. Could anyone help?


    <select name="bookwrapp ing"
    onchange="if(th is.selectedInde x)wrap=+(this[this.selectedIn dex].value);">
    <option value ="0">none</option>
    <option value="2.95">St andard Wrapping</option>
    <option value="3.95">De luxe Wrapping</option>
  • mickg77@hotmail.com

    #2
    Re: drop down menu returning 0 value

    sorry, please ignore.

    Comment

    • McKirahan

      #3
      Re: drop down menu returning 0 value

      "MickG" <mickg77@hotmai l.com> wrote in message
      news:1a9c775a.0 503150655.432f4 785@posting.goo gle.com...[color=blue]
      > Hi,
      >
      > I want my drop down box to be able to return wrap =0. It works fine
      > with 2.95 and 3.95 but does bot return a 0. Could anyone help?
      >
      >
      > <select name="bookwrapp ing"
      > onchange="if(th is.selectedInde x)wrap=+(this[this.selectedIn dex].value);">
      > <option value ="0">none</option>
      > <option value="2.95">St andard Wrapping</option>
      > <option value="3.95">De luxe Wrapping</option>[/color]

      What happens if you remove:
      "if (that.selectedI ndex) "


      Comment

      • mickg77@hotmail.com

        #4
        Re: drop down menu returning 0 value

        if, i choose none then it says that wrap is undefined.

        Comment

        • McKirahan

          #5
          Re: drop down menu returning 0 value

          <mickg77@hotmai l.com> wrote in message
          news:1110899281 .317746.124940@ o13g2000cwo.goo glegroups.com.. .[color=blue]
          > if, i choose none then it says that wrap is undefined.[/color]

          You've haven't posted enough of your code for us to know what you're really
          doing.

          Is it anything like the following? Watch for word-wrap.

          <html>
          <head>
          <title>wrap.htm </title>
          <script type="text/javascript">
          function wraps(that) {
          var wrap = that.options[that.selectedIn dex].value;
          alert(wrap);
          }
          </script>
          </head>
          <body>
          <form>
          <select name="bookwrapp ing" onchange="wraps (this)">
          <option value ="0" selected>none</option>
          <option value="2.95">St andard Wrapping</option>
          <option value="3.95">De luxe Wrapping</option>
          </form>
          </body>
          </html>


          Comment

          • Michael Winter

            #6
            Re: drop down menu returning 0 value

            mickg77@hotmail .com wrote:

            Please quote what you're responding to when replying to a post.
            [color=blue]
            > if, i choose none then it says that wrap is undefined.[/color]

            You can't choose 'None', at least not initially. The change event only
            fires when the value changes. As the first option is already
            selected[1], no change will occur. You have two options: place a dummy
            value in the SELECT element and have it selected by default, or
            initialise the wrap variable to zero (0) when you declare it. I'd
            probably go for the latter.

            Mike


            [1] You should always specify an initial option by including the
            selected attribute in the opening tag of an OPTION element.
            Do not rely the first option being selected by default.

            --
            Michael Winter
            Replace ".invalid" with ".uk" to reply by e-mail.

            Comment

            Working...