Dropdown list "onchange" help

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

    #1

    Dropdown list "onchange" help

    I have a "submit" button in a form that creates a record in my Filemaker
    database that works as it should. This is the HTML for it:

    <INPUT TYPE="SUBMIT" name="-New" VALUE="Add Record">



    I have a drop down list on that same form that works fine, but I want it to
    perform the same submit action as above once a value is chosen. This is the
    HTML for it:

    <SELECT NAME='CustNo' SIZE=1 onchange='Javas cript:document. form1.submit(); '>


    This performs the submit, but doesn't actually work. Somehow I need to pass
    the name="-New" parameter in the javascript for the record to be created in
    the database. How would I do that?


    Thanks.
  • Lasse Reichstein Nielsen

    #2
    Re: Dropdown list &quot;onchange& quot; help

    mdurgee@yahoo.c om (Mark Durgee) writes:
    [color=blue]
    > I have a "submit" button in a form that creates a record in my Filemaker
    > database that works as it should. This is the HTML for it:
    >
    > <INPUT TYPE="SUBMIT" name="-New" VALUE="Add Record">[/color]

    Seems correct. You are sure the server understands the minus in front
    of New correctly?
    [color=blue]
    > I have a drop down list on that same form that works fine, but I want it to
    > perform the same submit action as above once a value is chosen.[/color]

    That is a bad idea, since it prevents people from navigating using the
    keyboard. They will only be able to hit the first option.
    [color=blue]
    > This is the HTML for it:
    >
    > <SELECT NAME='CustNo' SIZE=1 onchange='Javas cript:document. form1.submit(); '>[/color]

    You don't need the "Javascript :" (unless you are writing for IE and
    having some other language as default script language for the page -
    all other browsers just parse it as a Javascript label).

    Since you are already in the form, you can just write:
    onchange="this. form.submit();"
    That would be equivalent to the onchange handler you had.
    [color=blue]
    > This performs the submit, but doesn't actually work. Somehow I need to pass
    > the name="-New" parameter in the javascript for the record to be created in
    > the database. How would I do that?[/color]

    You could probably go through a lot of hoops to get add the parameter,
    but I think the easiest way is:
    onchange="this. form.elements['-New'].click();"

    I still want you to reconsider submitting in the select onchange
    property.
    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • Mark Durgee

      #3
      Re: Dropdown list &quot;onchange& quot; help

      > > <INPUT TYPE="SUBMIT" name="-New" VALUE="Add Record">[color=blue]
      >
      > Seems correct. You are sure the server understands the minus in front
      > of New correctly?[/color]

      That's the button that works correctly.
      [color=blue][color=green]
      > > I have a drop down list on that same form that works fine, but I want it[/color][/color]
      to[color=blue][color=green]
      > > perform the same submit action as above once a value is chosen.[/color]
      >
      > That is a bad idea, since it prevents people from navigating using the
      > keyboard. They will only be able to hit the first option.[/color]

      I didn't really think of that until you mentioned it. However, these aren't
      power users and my own observation with people in this office is that many
      prefer clicking with the mouse - even though it's so inefficient.
      [color=blue]
      > You could probably go through a lot of hoops to get add the parameter,
      > but I think the easiest way is:
      > onchange="this. form.elements['-New'].click();"[/color]

      I got it to work by adding <INPUT TYPE="HIDDEN" name="-New" VALUE="Add
      Record"> at the top of the form and using onchange submit()
      [color=blue]
      > I still want you to reconsider submitting in the select onchange
      > property.[/color]

      I will definitely will take it into consideration. I'll probably build a
      page with a submit button and another that does it automatically and see
      what the users like better.

      Thanks for your help!

      Mark


      Comment

      Working...