I have the following JS. In this, when I press the submit button, I have a JS function that will create 2 input boxes and one more submit button.
When I type the values in those input boxes and click on the newly created submit button, the addition of the above input values should display. But the entire input boxes and submit button gets lost and the old page is getting displayed.
I don't know about that, but wouldn't it be better to have two submit buttons or include those two boxes that could pop up with a checkbox than making a user submit a form twice?
User experience is one problem, I agree. But here the functionality itself is not working.
I am not able to capture the inputs entered by the user in the newly created form. Thats what I want to solve.
-----------------------------------------------
If I understand your question correctly, there are two ways to do it...
I do not know java, but one of these basic methods should work. This is what I do in PHP:
PHP Code:
foreach($_POST as $key=>$value) { //Captures previously sent data and enters into new form variables for HTML Generation.
echo "<input type=\"hidden\" name=\"$key\" value=\"$value\">";
}
If you cannot find a Java equivalent to that, you can try this method:
A SUBMIT button is for submitting a FORM and usually changing the page location. Since
there is no FORM tag declaring an action URL, the default action of loading the current
page is taking place. So everything is working as expected.
What you should have used was a BUTTON.
<input type="button" value="ADD">
Why have you done to the trouble of programmatically creating all the form information
and inserting it into the document? It seems the point of the script was to investigate
object creation and document insertion rather than making a form to add two numbers.
Bookmarks