javascript - pass input value from one form to another form at same jsp page -


I have two forms in my jsp page, the first form has an input value and the other form The button is submitted, I can not use both forms due to some issue. Now I want to access the first form value in another form .

My sample code is here,

  & lt; Form name = "orange" id = "before" & gt; & Lt; Div & gt; & Lt; Input type = "article" name = "n1" & gt; & Lt; / Div & gt; & Lt; Select onchange = "document.forms ['onchange']. Submit ();" Name = "select" & gt; & Lt; Option value = "A" & gt; A & lt; / Options & gt; & Lt; Option value = "A" & gt; A & lt; / Options & gt; & Lt; / Form & gt; & Lt; Form action = "servlet" id = "seconds" & gt; & Lt; Input type = "submit" name = "sub" value = "submit" & gt; & Lt; / Form & gt;   

I need to access a first form value for the second form at Submit . Is there any way to use it? Thank you.

I do not know exactly what you want to do. But you can not send a form data using another form using the submit button.

You can talk one thing either using the session or you can use hidden fields in which there is a submit button. You can pass the values ​​from the first form to the hidden fields of another form. Can use javascript / jquery for Then you can submit the form.

Otherwise you can use the easiest session.

IN Jquery

  & lt; Forms & gt; & Lt; Input type = "text" class = "input-text" value = "" size = "32" name = "user_data [first name]" id = "elm_6" & gt; & Lt; Input type = "text" class = "input-text" value = "" size = "32" name = "user_data [lastname]" id = "elm_7" & gt; & Lt; / Form & gt; & Lt; Form action = "#" & gt; & Lt; Input type = "text" class = "input-text" value = "" size = "32" name = "user_data [b_firstname]" id = "elm_14" & gt; & Lt; Input type = "text" class = "input-text" value = "" size = "32" name = "user_data [s_firstname]" id = "elm_16" & gt; & Lt; Input type = "submit" value = "continue" name = "send [checkout.update_steps]" & gt; & Lt; / Form & gt; Val ($ ('# elm_6'). Val ()); $ ('# Elm_16'). Val ($ ('# Elm_7'). Val ());});   

This is jsfiddle for

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -