SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: submit()

  1. #1
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    submit()

    I have been looking for, but have not found, nor do I know if it is even possible to pass a value to the server using the method "submit()".

    I have a form that has 3 different buttons, and each tells the server side script to react differently to the data it is sent.

    One of the fields is a select box, and I want it to behave the same way that the select box does at the bottom of the forums; when the selected value in the select box changes, the submission takes place automatically. However, I need to send along with the form data, a key word or value to the recieving script.

    Is there a way to do this using: onchange = "this.form.submit();" ?
    John

  2. #2
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Is GET data OK?
    Code:
    function selectPage(objSelect) {
       location.href='http://www.site.com/blah.php?foo='+objSelect[objSelect.SelectedIndex].Value;
    }
    and then I just reread your question and maybe that's not what you are looking for. I just had a play and this works for me
    HTML Code:
    <form method='post'>
    <select name='foo' onChange='this.form.submit()'>
    	<option selected='selected'>---</option>
    	<option value='bar'>Bar</option>
    </select>
    </form>

  3. #3
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks DR.

    I implemented it in my code:
    PHP Code:
            <td align="left">
              <
    select name="themeId" tabindex="1" onchange="this.form.submit();">
                 <
    option value=""> </option>
                 <
    option value="05">Default</option>
                 <
    option value="03" selected>Boo</option>
              </
    select>
            </
    td
    But I get this error:
    Line: 81
    Char: 1
    Error: Object does not support this property or method.
    Line 87 is: <td align="left">

    I'm not all that experienced with JavaScript, so any help understanding this is greatly appreciated!
    John

  4. #4
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    John

  5. #5
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Nice link


Bookmarks

Posting Permissions

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