Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7057351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:58:32+00:00 2026-05-28T03:58:32+00:00

I want to have a JSP like this: <form id=form1> Name is: <%=request.getParameter(name) %>

  • 0

I want to have a JSP like this:

<form id="form1">
 Name is: <%=request.getParameter("name") %>
 <a href="#" onclick="fun1('<%=request.getParameter("name") %>')">Show Email Form</a>
</form>

<form id="form2">
 <input type="text" name="emailid" />
 <a href="#" onclick="fun2('$('input[name=emailid]').val()', <name required here>)">Submit</a>
</form>

My javascript is something like this:

function fun1() {
 //Nothing important here, just show second form
 $('#form2').show();
}

function fun2(myemail, myname) {
 //Do something important here,
 //Like update email for the given name
 xmlhttp = GetXmlHttpObject();
 var url = "updateEmail.do?email=" + myemail + "&name=" + myname;
 xmlhttp.open("POST", url, true);
}

Things to note here:
1) There is no action tied to my form, I am submitting the second form through Ajax.
2) I need to have two different forms, first form has more elements besides Name. And the second form has another different set of elements besides the email. Only one of the functions (fun2) in form2 needs both parameters of the name from form1 and email id from form2.
3) Form1 has an uneditable name parameter, and form2 has an editable email parameter. The onclick function in form2 picks up the email text input with jQuery.
4) One other scenario to consider is if there are multiple entries of name in form1, like a list of names using loops. Eg,

<form id="form1">
 <logic:iterate id="record" name="peoplerecords" property="records">
  Name is: <bean:write name="record" property="name">
 <a href="#" onclick="fun1('<bean:write name="record" property="name">')">Show Email Form</a>
 </logic:iterate>
 </form>

What is the best way to write the name parameter from form1 into the javascript onclick url in form2?

form1 :- onclick=”fun1(name);”
form2 :- onclick=”fun2(email, name);”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:58:33+00:00Added an answer on May 28, 2026 at 3:58 am

    You can either directly put the name in with JSP:

    <a href="#" onclick="fun2($('input[name=emailid]').val(), <%=request.getParameter("name") %>)">Submit</a>
    

    Or you can give the dom node containing the name an id and access it with jQuery

    Name is: <span id="nameNode"><%=request.getParameter("name") %></span>
    
    
    <a href="#" onclick="fun2($('input[name=emailid]').val(), $('#nameNode').innerHTML)">Submit</a>
    

    Also consider getting the required parameters directly in your functions or define the onclick handlers in your script section to avoid the code getting messy. Watch out for the quotes inside HTML attributes, you used single quotes twice in the second onclick handler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple HTML form like this: <form name='input' action='thankyou.jsp' method='post'> <p>Email Address:
I have a form like this - <form method='post' name='FormName' action=next.jsp> <INPUT TYPE=hidden NAME=language
If I have a checkbox like this in my jsp: <form:checkbox path=agreeToLegalAgreements /> It
I have a form JSP web page, this form contains multiple instances of the
Hello i have a JSP page that contain a form, i want to validate
I have webpage with a form like this: <html> <head> ... </head> <body> <form
I have Vector declared in index.jsp page like this: <%! Vector vNumbers = new
Currently, I have a commandButton element in my jsp declared like this: <h:commandButton id=saveButton
I have the following form from http://regain.sourceforge.net/ : <form name=search action=search.jsp method=get> <p class=searchinput>
I have a simple jsp/servlet application and I want to add AJAX feature to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.