Dropdown list "onchange" help

M

Mark Durgee

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='Javascript: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.
 
L

Lasse Reichstein Nielsen

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">

Seems correct. You are sure the server understands the minus in front
of New correctly?
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.

That is a bad idea, since it prevents people from navigating using the
keyboard. They will only be able to hit the first option.
This is the HTML for it:

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

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.
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?

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
 
M

Mark Durgee

Seems correct. You are sure the server understands the minus in front
of New correctly?

That's the button that works correctly.
That is a bad idea, since it prevents people from navigating using the
keyboard. They will only be able to hit the first option.

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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top