1 submit button 2 forms jquery

Greetings, i have the following code which just basically displays a text file after you click the submit button.
If i put all the choices in 1 form it works fine. If i have 2 separate forms using the same submit button it doesn’t work. How do i use 2 forms with the same submit button. My 2 forms version is pasted below. Thanks again.

[php]

Log View:

New York New York New York
London London London
Submit Query
[/php]

If you use two separate forms, you have two separate form buttons. The buttons submit the forms.
Just use one form and two submit buttons if they are needed.

So, the actual and should be around both forms. You are thinking that you have two forms, but, you really only have one with two fields in it. Two drop-downs, but, really only one form. Did that make sense?

So, something like this:
[php]

Log View:

New York New York New York
London London London
Submit Query
[/php]

Hi Ernie,
i tried this out but it gives me the same result. All of the selections from the first drop down work, but the 2nd drop down choices just sit there when you select one them.

Sorry, forgot to change the second drop-down’s to a new name.

You can NOT use the same name for two drop-down’s. If you want both to be used,
just change the second one’s name to “region2” and use that when you read it. Then, you
will get both drop-down’s values.

If you keep them the same and one to read them as one name, you can use arrays.
Such as , but, this can be tricky to deal with once you read
it back in. If there are a large number of drop-downs, arrays are okay. But, for just two
drop-downs, just change the second one’s name.

Also, if you use Javascript or JQuery to handle data from the clauses, you either have
to use arrays or add each separate command for each clause. So, pulling data from them,
you would have to use two JQ commands, one for each …

Hope that explains it enough. Good luck!

yes thanks. I have a follow up question although maybe i should start a new post. Is there a preload capability in php or html where after the user hits the submit button the page will say loading or actually show a progress bar or percentage counter ?

Well, yes and no…

First, you must remember to understand how PHP works. It is a SERVER-SIDE programming tool.
Browser’s work on your local machine and are CLIENT-SIDE only. Javascript and JQuery are handled
in the browser, so they are also CLIENT-SIDE tools.

What does that mean for a progress bar? Well, you enter data on your a form. Forms are inside
your browser, so they are CLIENT-SIDE. They are POSTED to the server. When the server gets an
order to handle your form info, if it is a PHP script, it first handles the PHP code. This outputs whatever
it does to a page which is then sent to the Browser. Then, in the browser, JS/JQ and CSS all take over
before you see the results.

Now, this means that a progress bar is handled CLIENT-SIDE. usually, it is with some sort of counter
that tracks how much of a file is sent so far. This would all be CLIENT-SIDE. Hope that makes sense.

To do this, there are literally thousands of ways to do it. Here are examples on sites that walk you thru it:

This one seems simple enough:
http://w3shaman.com/article/php-progress-bar-script

This one is very simple, uses JS and the second sample code uses no images, just simple CSS
for the graphics. A nice solution I think!
http://bytes.com/topic/javascript/insights/740574-extremely-simple-progress-bar

This one uses XML/JS/PHP/AJAX and is well behaved with some options:
http://www.sitepoint.com/tracking-upload-progress-with-php-and-javascript/

This one might be a bit complicated…
http://stackoverflow.com/questions/20453015/progress-bar-ajax-and-php

So, there are lots of solutions for you to study. Take your pick. Might select the second one if me…

excellent. Ill give it a shot. ;D

Sounds great! I am marking this thread as solved. If you run into further issues, please start a new post and we will continue there. Looks like you are making progress. Always a nice thing!

Sponsor our Newsletter | Privacy Policy | Terms of Service