My current code is as follows:
<div class="fr_search"> <form action="/" accept-charset="UTF-8" method="post" id="search-theme-form"> ....... </form> </div>
Now I want to write a function to change the form action and method, when a condition is met. How do I write this code?
For example,
function test() { if (selectedIndex === 1).... } // How do I write this code?
In an HTML form, the action attribute is used to indicate where the form's data is sent to when it is submitted. The value of this can be set when the form is created, but at times you might want to set it dynamically.
Call the . clone() method on the selector which you want to copy and insert the newly created element in your existing HTML layout using append, pretend, insertAfter, etc.
Let's learn the steps of performing multiple actions with multiple buttons in a single HTML form: Create a form with method 'post' and set the value of the action attribute to a default URL where you want to send the form data. Create the input fields inside the as per your concern. Create a button with type submit.
function chgAction( action_name ) { if( action_name=="aaa" ) { document.search-theme-form.action = "/AAA"; } else if( action_name=="bbb" ) { document.search-theme-form.action = "/BBB"; } else if( action_name=="ccc" ) { document.search-theme-form.action = "/CCC"; } }
And your form needs to have name
in this case:
<form action="/" accept-charset="UTF-8" method="post" name="search-theme-form" id="search-theme-form">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With