use a select as a submit button!

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

    use a select as a submit button!

    Is there a way to use a value of in the pick list as a submit button?
    If I select a value in a drop down box, it will be submitted to the next page.
  • David Dorward

    #2
    Re: use a select as a submit button!

    reneecccwest wrote:
    [color=blue]
    > Is there a way to use a value of in the pick list as a submit button?
    > If I select a value in a drop down box, it will be submitted to the next
    > page.[/color]

    You can use JavaScript to call the submit() method of the form onchange for
    the select... but this is generally considered a bad idea.

    1. You need a submit button anyway (JavaScript doesn't work universally)
    2. The normal behaviour of select elements does not cause the page to
    change. People might[1] change their mind and not want to make a selection
    - but once they've started, they are rather stuck with it.

    [1] Scratch that. They _will_.

    --
    David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>

    Comment

    • Lee

      #3
      Re: use a select as a submit button!

      reneecccwest said:[color=blue]
      >
      >Is there a way to use a value of in the pick list as a submit button?
      >If I select a value in a drop down box, it will be submitted to the next page.[/color]

      Yes. You had better be sure that all visitors have Javascript, though.

      <html>
      <body>

      <form action="http://www.google.com/search">
      <select name="q" onchange="this. form.submit()">
      <option>Choos e one...</option>
      <option>javascr ipt</option>
      <option>onchang e</option>
      <option value="event+ha ndler">event handler</option>
      </select>
      </form>

      </body>
      </html>

      Comment

      • reneeccc west

        #4
        Re: use a select as a submit button!

        btw is there anyway i can define and get a value of this.form.submi t()?

        thanks again
        RC

        *** Sent via Developersdex http://www.developersdex.com ***
        Don't just participate in USENET...get rewarded for it!

        Comment

        • bruce

          #5
          Re: use a select as a submit button!

          reneecccwest@ho tmail.com (reneecccwest) wrote in message news:<c1c86eae. 0405180904.4368 0d55@posting.go ogle.com>...[color=blue]
          > Is there a way to use a value of in the pick list as a submit button?
          > If I select a value in a drop down box, it will be submitted to the next page.[/color]

          You can use any control, or any tag as a "submit". Simply put an
          "onclick=DoSubm it()" clause in the tag. Then in the javascript
          function "DoSubmit() ", have lines that look like this:

          DoSubmit()
          {
          form1.method=po st
          form1.action=Ne xtPage.html
          form1.submit()
          }

          Comment

          • Randy Webb

            #6
            Re: use a select as a submit button!

            bruce wrote:
            [color=blue]
            > reneecccwest@ho tmail.com (reneecccwest) wrote in message news:<c1c86eae. 0405180904.4368 0d55@posting.go ogle.com>...
            >[color=green]
            >>Is there a way to use a value of in the pick list as a submit button?
            >>If I select a value in a drop down box, it will be submitted to the next page.[/color]
            >
            >
            > You can use any control, or any tag as a "submit". Simply put an
            > "onclick=DoSubm it()" clause in the tag. Then in the javascript
            > function "DoSubmit() ", have lines that look like this:
            >
            > DoSubmit()
            > {
            > form1.method=po st
            > form1.action=Ne xtPage.html
            > form1.submit()
            > }[/color]

            Thats assuming the browser is IE.

            document.forms['form1'].method = 'POST';
            document.forms['form1'].action = 'NextPage.html' ;
            document.forms['form1'].submit();

            The method and action should be quoted so that script doesn't attempt to
            interpret as a variable.


            --
            Randy
            Chance Favors The Prepared Mind
            comp.lang.javas cript FAQ - http://jibbering.com/faq/

            Comment

            • bruce

              #7
              Re: use a select as a submit button!

              Randy Webb <hikksnotathome @aol.com> wrote in message news:<LtydnTNrE oAaiyvdRVn-jg@comcast.com> ...[color=blue]
              > bruce wrote:
              >[color=green]
              > > reneecccwest@ho tmail.com (reneecccwest) wrote in message news:<c1c86eae. 0405180904.4368 0d55@posting.go ogle.com>...
              > >[color=darkred]
              > >>Is there a way to use a value of in the pick list as a submit button?
              > >>If I select a value in a drop down box, it will be submitted to the next page.[/color]
              > >
              > >
              > > You can use any control, or any tag as a "submit". Simply put an
              > > "onclick=DoSubm it()" clause in the tag. Then in the javascript
              > > function "DoSubmit() ", have lines that look like this:
              > >
              > > DoSubmit()
              > > {
              > > form1.method=po st
              > > form1.action=Ne xtPage.html
              > > form1.submit()
              > > }[/color]
              >
              > Thats assuming the browser is IE.
              >
              > document.forms['form1'].method = 'POST';
              > document.forms['form1'].action = 'NextPage.html' ;
              > document.forms['form1'].submit();
              >
              > The method and action should be quoted so that script doesn't attempt to
              > interpret as a variable.[/color]

              Thanks for the correction!

              Comment

              Working...