Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. javascript error...

javascript error...

Scheduled Pinned Locked Moved Web Development
javascriptcomjsonhelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    l a u r e n
    wrote on last edited by
    #1

    ok so i have a form that has a droplist in it when the selection changes i want to fire the submit event so i add this: <form name='fp' method='post' action='blah.blah'> <select name='fptype' onChange='document.fp.submit()'> --- rest of form --- </form> and all i get is errors saying: document.fp.submit is not a function am i being an idiot or did something change when i wasnt looking? :wtf:


    "there is no spoon"
    biz stuff   about me

    A 1 Reply Last reply
    0
    • L l a u r e n

      ok so i have a form that has a droplist in it when the selection changes i want to fire the submit event so i add this: <form name='fp' method='post' action='blah.blah'> <select name='fptype' onChange='document.fp.submit()'> --- rest of form --- </form> and all i get is errors saying: document.fp.submit is not a function am i being an idiot or did something change when i wasnt looking? :wtf:


      "there is no spoon"
      biz stuff   about me

      A Offline
      A Offline
      Andrew Quinn AUS
      wrote on last edited by
      #2

      uhm, I tried the exact code you described and it worked for me (in IE that is). Are you using a different browser? As reference though, this is a more programatically correct approach:

      <!--
      function onchangeOptions()
      {
      var frm = document.getElementById("fp");
      if (frm) frm.submit();
      }
      //-->

      1
      2

      We've included the id attribute for the <form> and so we can use: getElementById DOM method which is better than using the document.elementname approach as this searches through all the DOM collections. With multiple FORMs on the page (in my experience) the latter didn't always return the object, whereas the former does. Anyway, hope this helps Cheers, Andy

      L B 2 Replies Last reply
      0
      • A Andrew Quinn AUS

        uhm, I tried the exact code you described and it worked for me (in IE that is). Are you using a different browser? As reference though, this is a more programatically correct approach:

        <!--
        function onchangeOptions()
        {
        var frm = document.getElementById("fp");
        if (frm) frm.submit();
        }
        //-->

        1
        2

        We've included the id attribute for the <form> and so we can use: getElementById DOM method which is better than using the document.elementname approach as this searches through all the DOM collections. With multiple FORMs on the page (in my experience) the latter didn't always return the object, whereas the former does. Anyway, hope this helps Cheers, Andy

        L Offline
        L Offline
        l a u r e n
        wrote on last edited by
        #3

        thnx a lot for the post i did fix it already tho and it was a dumb pfu i had a button called submit on the form doh!! and yah its not just for ie :)


        "there is no spoon"
        biz stuff about me

        1 Reply Last reply
        0
        • A Andrew Quinn AUS

          uhm, I tried the exact code you described and it worked for me (in IE that is). Are you using a different browser? As reference though, this is a more programatically correct approach:

          <!--
          function onchangeOptions()
          {
          var frm = document.getElementById("fp");
          if (frm) frm.submit();
          }
          //-->

          1
          2

          We've included the id attribute for the <form> and so we can use: getElementById DOM method which is better than using the document.elementname approach as this searches through all the DOM collections. With multiple FORMs on the page (in my experience) the latter didn't always return the object, whereas the former does. Anyway, hope this helps Cheers, Andy

          B Offline
          B Offline
          Bjoern Graf
          wrote on last edited by
          #4

          Never ever submit a form onchange of a select! Reasons:

          1. the user is not able to select options with the keyboard
          2. when the user uses the mouse wheel and the select has focus the form is again submitted by accident
          3. the form will not be submitted if the user has JS disabled

          Having that said here's another programatically correct approach:

          <script type="text/javascript">
          function doSubmit(frm) {
          frm.submit();
          }
          </script>
          ...
          <select onchange="doSubmit(this.form)">

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups