Use a Java Script variable's value in some other  jsp ....how?

Please help me.................
<%@ page import="java.util.*" %>
<%@ page language = "java" import="java.sql.*,javax.servlet.*,javax.servlet.http.*,java.util.*" session = "true" %>
<HTML>
<HEAD>
<TITLE>Create Employee</TITLE>
</HEAD>
<BODY>
<%
     Connection conn = null;
     Statement stmt = null;
     ResultSet rs = null;
     try {
          Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://10.203.143.55:3306/bdaymgr" ,"root","mysql");
          stmt = conn.createStatement();
          rs = stmt.executeQuery("Select emp_id,emp_name From employee_info ");
          System.out.println("rs " + rs);
%>
<script language="JavaScript">
     function OnSubmitForm(){
     var box = document.form2.UserList;
     var where_to = box.options[box.options.selectedIndex].value;
     if(where_to =="")
{document.write("Please select something");}
     else {Dont know what to do here }
     </script>
</script>
<center>
<FORM NAME = "form2" onSubmit="OnSubmitForm();">
<table>
<TR>
     <TD width="11%">User ID : </TD>
     <TD width="180%"><select name="UserList" size="1">
     <option>-- Select A User ID --<option>
     <% while (rs.next()) {
     %>
     <option value='<%= rs.getString("EMP_ID")%>' ><%=rs.getString("EMP_ID") %></option>
     <% } %>
     </select>
     <input type="hidden" name="score" value="">
     <INPUT TYPE="SUBMIT" name="Submit" VALUE="Submit">
     </TD></TR>
</TABLE>
</FORM>
</Center>
<%
          stmt.close();
               rs.close();
          catch(Exception e){
               System.out.println("Error : "+ e);
               response.sendRedirect("errorcreateSession.jsp");
%>
</BODY>
</HTML>
As u can see i have extracted emp_id from the employee_info table and populated it in my drop down list
In the javascript i have used a variable "where_to" which keeps track of what the user has selected in the drop down list
I want to use this value of "where_to" in some other other jsp(say Admin.jsp) to carry out an insert query
how can i retrieve this value of "where_to" from Admin.jsp so that i can carry out my insert query
Thanx in advance i certainly hope that u will help me

I made these changes in my Guest.jsp page(as u mentioned):
<FORM NAME = "form2" onSubmit="return OnSubmitForm();" action="Admin.jsp">
<select name="UserList" size="1">
     <option>-- Select A User ID --<option>
</select>
     <INPUT TYPE="SUBMIT" name="Submit" VALUE="Submit">
<script language="JavaScript">
     function OnSubmitForm(){
     var box = document.form2.UserList;
     var where_to = box.options[box.options.selectedIndex].value;
     if(where_to =="")
document.write("Please select something");
return false;
else
return true;
</script>
Now have a look at my Admin.jsp page:
<%@ page import="java.util.*" %>
<%@ page language = "java" import="java.sql.*,javax.servlet.*,javax.servlet.http.*,java.util.*" session = "true" %>
<HTML>
<HEAD>
<TITLE>Create Employee</TITLE>
</HEAD>
<BODY>
<%
     Connection conn = null;
     Statement stmt = null;
     ResultSet rs = null;
     PreparedStatement ps = null;
     try {
          Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://10.203.143.55:3306/bdaymgr" ,"root","mysql");
          String s=request.getParameter("UserList");
          String m=request.getParameter("month");
          String y=request.getParameter("year");
          String a=request.getParameter("amount");
          String sql="insert into contribution_info values(?,?,?,?)";
          ps=conn.prepareStatement(sql);
          ps.setString(1,s);
          ps.setString(2,m);
          ps.setString(3,y);
          ps.setString(4,a);
          ps.executeUpdate();
          System.out.print("Values Entered");
          %>
<center>
<FORM NAME = "form3" action="canBeAnyPage.jsp">
Month :<br><input type=\"text\" name="month"><br>
Year :<br><input type=\"text\" name="year"><br>
Amount Paid :<br><input type=\"text\" name="amount"><br>
<INPUT TYPE="SUBMIT" name="Submit" VALUE="Submit">
</FORM>
</center>
<% stmt.close();
               rs.close();
          catch(SQLException e){
               System.out.println("Error : "+ e);
               //response.sendRedirect("errorcreateSession.jsp");
%>
</BODY>
</HTML>
I dont know why but when i select one of the emp_id from the drop down list and press submit it does not show anything
I can see the value of "UserList" in the url which is correct
Probably there is some problem in my Admin.jsp page
Please find time to have a look at my code
Help would be really appreciated
thanx

Similar Messages

  • How to assign java script variable to a hidden parameter in JSP?

    Hi All,
    I want to assign the variable in the Jscript to a hidden parameter in JSP page.
    <select name="sortingOption" class="sortingOptions" onchange="changeSortOption(this)">
    <c:forEach var="sortingOption" items="${sortingOptionList}">
    <c:set var="sortingOptionValue" value="${sortingOption}" target="java.lang.String"/>
    <c:choose>
    <c:when test="${sortingOptionValue == sortingOptionValueFromRequest}">
    <option value="${sortingOptionValue}" selected="selected">${sortingOptionValue}</option>
    <input type="hidden" name="srchType" value="none"/>
    </c:when>
    <c:otherwise>
    <option value="${sortingOptionValue}">${sortingOptionValue}</option>
    </c:otherwise>
    </c:choose>
    </c:forEach>
    </select>
    In changeSortOption script,they capture the value selected by the user and then they submit the form.I want to assign that value to a hidden parameter in JSP,can someone tell me how to do that?
    I dont have the Jscript code with me right now to post here.

    To the point: just by accessing/manipulating the HTML DOM using JS. Learn JS and HTML DOM. There are basic tutorials at w3schools.com. Besides, your code syntax is still invalid. The input hidden elemend doesn't belong in a select element. Learn HTML. There's a basic tutorial at w3schools.com as well.
    For future HTML/JS problems please consult the appropriate forums. This has not much to do with JSP. There are ones at webdeveloper.com.

  • Returning/passing Java script variable/value to PL/SQL environment

    Hi,
    Can someone give me a sample code about how to return a Java script variable to PLSQL environment?
    for example, I have a javascript function that returns timestamp in milisecond, I then want to write PLSQL code to call this java script function and save its value in a number-typed plsql variable for further calculation, I dont know how the two scripting language communicate.
    Thank you very much
    Binh
    null

    This is quite simple.
    I assume that you are able to define html form side through pl/sql. Suppose your new pl/sql value is v_time then in the procedure that you write include one more statement
    htp.p('<Input type=hidden name="v_time" value="">');
    and also in the form invocation,
    htp.p('<form name=app method=post action="time_handler" onSubmit="return false;">');
    and to the end you must be having a submit
    to it attach a onClick function that calls
    simply our validate function..
    eg htp.p('<Input type=submit value="process"
    onClick="validate();">');
    Include in the head portion
    the following script using htp.p procedure
    function validate()
    app.v_time.value=<calculated value>;
    return app.submit();
    Hope this helps.
    Nat
    null

  • Passing importing parameter in  ABAP to  java script variable

    Hi Experts,
    I am calling a ABAP function module in javascript.Now how can I take importing parameter in  ABAP to java script variable. Because I need to give alert using the improting Paramter value...
    Thanks in advance..
    RR

    to pass ABAP variable value to javascript variable the syntax is
    var myjsvariable = "<%=abapvariable%>";
    Edited by: Durairaj Athavan Raja on Jul 29, 2009 2:39 PM

  • How to Use the JAVA SCRIPT code in .htm page of the component

    Hi .
    In my requirement i have to use Java Script Function in .htm code ..how to use the java script code and functions in .htm???
    thank you
    B.Mani

    Check this document  [Arun's Blog|http://wiki.sdn.sap.com/wiki/display/CRM/CRMWebClientUI-TalkingwithJava+Script]
    Regards
    Kavindra

  • How to access a JAVA Script variable in JSP Code

    How to access a JAVA Script variable in JSP Code. I have been unable todo this.
    Plz Suggest a way.
    Thanks
    Soumya

    try to do this code
    String s=request.getParameter("javascriptvariablename");

  • Whenever i open gmail it appears which says-"java script application,Error: Illegal operation on WrappedNative prototype ",how this will resolve,anyhow.object

    Question
    whenever i open gmail it appears which says-"java script application,Error: Illegal operation on WrappedNative prototype ",how this will resolve,anyhow ?

    This is usually caused by an extension that is using a name for a variable or function that has become a reserved variable name and thus can't be used anymore.<br />
    You will have to check if there is an update is available for your Firefox 29.0a2 Aurora version.
    If it works in Safe Mode and in normal mode with all extensions (Firefox/Tools > Add-ons > Extensions) disabled then try to find which extension is causing it by enabling one extension at a time until the problem reappears.
    Close and restart Firefox after each change via "Firefox > Exit" (Windows: Firefox/File > Exit; Mac: Firefox > Quit Firefox; Linux: Firefox/File > Quit)
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • Using a java script comfirmation in delete record function?

    Hello;
    I am trying to write a confirmation script in Java to delete
    a record. I don't want it to delete the whole table of information,
    just the record teh delete button is attached to using the ID. Here
    is my script, and then the code on the page:
    <script language="JavaScript">
    function confirmDelete(id) {
    if (confirm ("Are you sure you want to delete this record?"))
    document.HREF.action="ProjectCat-Action.cfm?id="+id;
    document.HREF.submit();
    return false;
    </script>
    Here is the query I am trying to use it with:
    <cfquery name="catMan" datasource="#sitedatasource#"
    username="#siteUserID#" password="#sitePassword#">
    SELECT Categories.Name AS ViewField1, Categories.CategoryID
    AS ID
    FROM Categories
    </cfquery>
    <head>
    </head>
    <body>
    <cfloop query="catMan" startRow="#URL.startRow#"
    endrow="#endRow#">
    <cfoutput>
    #ViewField1#
    <form action="ProjectCat-Action.cfm" method="post">
    <input type="hidden" name="ID" value="#ID#">
    <input type="submit" name="proj_Delete" onClick="return
    confirmDelete('#ViewField1#')" value="Delete"></form>
    </cfoutput>
    </cfloop>
    </body>
    #Note: there is code here in my loop query for next and
    previous buttons, I just didn't post that code because it doesn't
    pertain to this question.
    Is there also a way to make the Java Script state in the spot
    where it says, "Are you sure you want to delete this record" to
    make it say "Are you sure you want to delete #ViewField1#?" (the
    name of the record being deleted) ?
    Thank you!
    Phoenix

    just pass 2 arguments to your js function - id AND name of
    category:
    <input type="submit" name="proj_Delete" onClick="return
    confirmDelete(#ID#,'#ViewField1#')" value="Delete">
    and the function:
    function confirmDelete(id,name) {
    if (confirm ("Are you sure you want to delete " + name + "
    category?"))
    document.HREF.action="ProjectCat-Action.cfm?id="+id;
    document.HREF.submit();
    return false;
    but creating a separate form for each category displayed on
    the page is
    very inefficient - you should revise your code... you do not
    even need a
    form, really... just use <a href=...> to call your js
    function, or an
    <input type=button ...> (without any <form ..>
    tags) if you absolutely
    must have a button to click...
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com

  • Use of java script in WAD.

    Hi.
    I need to write java script for reading column heading  of a table (analysis grid in WAD) and check if heading has a particular  value suppose ‘X’ , I need to highlight that column heading with a color.Kindly provide some pointers .
    Thanks in advance,
    Neetika.

    I have somehow managed to workaround the issue.
    I use one aggregation level without Stage field to allow users to modify the data and then I use another aggregation level with Stage field to process the Stages using planning functions and filters. This works.
    I am still curious on the user exit proposed by Andrey.
    Andrey can you please provide step by step on how we achieve this?
    Thanks,
    DV

  • How do I use a Java script in place of a standard link?

    Hi! I'm very new to html and totally unfamiliar with Java. Basically my html has a link like this: Mr Nobody and I didn't like how easy it was for spammers to harvest that email address from my website. I looked at this site http://www.bronze-age.com/nospam/ which allowed me to download a javascript .js file and some instructions on how to recode my email link so that it's hidden.
    I've loaded the java procedure in the head of the html just like the website says. He says that every link must be converted to a script call; so what previously was Mr Nobody changes to <script>mail2("nobody","fake.address9z",0,"","Mr Nobody")</script>. What does this mean? I replaced the stuff from the inside of the quotes in the href and weird stuff happens. What do I actually replace or how do I call up this script?
    I basically have created an image mapped link that I want to call this javascript when clicked.
    thanks for any help!! :)

    cotton.m wrote:
    BigDaddyLoveHandles wrote:
    cotton.m wrote:
    BigDaddyLoveHandles wrote:
    cotton.m wrote:
    BigDaddyLoveHandles wrote:
    nclow wrote:
    BigDaddyLoveHandles wrote:
    nclow wrote:
    Beats me. Read the documentation. Or ask on a javascript forum, but they'll probably tell you the same thing.Yeah, they're all a bunch of ASCII porn lovers.Really, who isn't?!Even the sounds of an impact printer pounding out a solid page of characters gives me a thickie.Well actually... unless you're in the habit of using mustard during foreplay, and really who can tell, then I think that's actually one of them cd-rom hotdogs that you dropped in your lap.Is it too late to mention what a cultured and sophisticated person I am?If by cultured you are referring to bacterial growth between your toes then yes I think we covered this.It's just that I'm still holding out for that sponge bath from Fiest.Well if she ever gets off Bravo I'll send her your way.
    But not on the train. Yikes!Sigh... It's just that I've got that big guy's weakness for bony women...

  • Assigning a jstl variable to java Script variable

    Hai All,
    I created one jsp page with java script with JSTL.
    I retrive arrayList from simple java bean in jsp page with help of JSTL .
    Now i want assign the ArrayList value through JSTL to Java Script Array.
    How to convert JSTL to Java Script.
    Please give me details asp.
    thanks ,
    Bala

    You can do this:
    <% request.setAttribute("x", "hello"); %>
    <c:out value="${x}"/>or if you want to go from JSTL to scriplet you can:
    <c:set var="testvar" value="hello" scope="request"/>
    <%= request.getAttribute("testvar") %>Both of these will output "hello"
    <c:set> defaults to the page scope, so you could substitute pageContext for request and get the same results (remove scope="request" first though).
    Karl

  • Hi i have pop up ads everywhere in safari and I'm new to using a mac can someone help me with some info on how to secure myself from this occurring

    Hi I need some help with pop up ads there everywhere in safari is there a anti phishing product i should install or settings that need to be changed I'm new to using apple and would love some help here.

    There is no need to download anything to solve this problem.
    You may have installed one or more of the common types of ad-injection malware. Follow the instructions on this Apple Support page to remove it. It's been reported that some variants of the "VSearch" malware block access to the page. If that happens, start in safe mode by holding down the shift key at the startup chime, then try again.
    Back up all data before making any changes.
    One of the steps in the article is to remove malicious Safari extensions. Do the equivalent in the Chrome and Firefox browsers, if you use either of those. If Safari crashes on launch, skip that step and come back to it after you've done everything else.
    If you don't find any of the files or extensions listed, or if removing them doesn't stop the ad injection, ask for further instructions.
    Make sure you don't repeat the mistake that led you to install the malware. It may have come from an Internet cesspit such as "Softonic" or "CNET Download." Never visit either of those sites again. You might also have downloaded it from an ad in a page on some other site. The ad would probably have included a large green button labeled "Download" or "Download Now" in white letters. The button is designed to confuse people who intend to download something else on the same page. If you ever download a file that isn't obviously what you expected, delete it immediately.
    Malware is also found on websites that traffic in pirated content such as video. If you, or anyone else who uses the computer, visit such sites and follow prompts to install software, you can expect more of the same, and worse, to follow. Never install any software that you downloaded from a bittorrent, or that was downloaded by someone else from an unknown source.
    In the Security & Privacy pane of System Preferences, select the General tab. The radio button marked Anywhere  should not be selected. If it is, click the lock icon to unlock the settings, then select one of the other buttons. After that, don't ignore a warning that you are about to run or install an application from an unknown developer.
    Still in System Preferences, open the App Store or Software Update pane and check the box marked
              Install system data files and security updates (OS X 10.10 or later)
    or
              Download updates automatically (OS X 10.9 or earlier)
    if it's not already checked.

  • Pass value of Java script variable to ABAP variable (in BSP)

    Hi,
    I have a Javascript variable declared in the SCRIPT tag of BSP layout page.
    I want to pass its value to ABAP variable, so that later I can do some computations using the ABAP variable.
    (ABAP variable is also declared in the same SCRIPT tag of BSP page)
    Would request to post a sample code, if possible.
    Would appreciate quick replies.
    Thanks & Regards,
    Nisha Vengal.

    just check this
    https://forums.sdn.sap.com/click.jspa?searchID=16240444&messageID=1191305

  • How to pass a java script variable to a JSP page

    How to assign a javascript variable value to a jsp variabe
    <script>
    var scroll="100"
    </script>
    <%
    String age=[ here i need to set the value of "scroll" ]
    %>
    is it possible ,
    thanks

    assign this scroll to a hidden field in a form
    and pass via form to server this may be one way or
    set attribute scroll and then access to server side
    may this help you
    --yogeshb                                                                                                                                                                                                                                                                                                                                                                           

  • How to store resultset value to  Some other variable

    ResultSet rset1=stmt1.executeQuery("SELECT count(*) FROM
    user_details_table" );
    while(rset1.next())
    System.out.println("No.of Connected Users In UserDetails Table: " + rset1.getInt(1));
    int x=rset1.getInt(1);
    to store tht resultset value into integer variable.Bt tht statement is giving error. Pls help me.
    Thanks....

    try
    ResultSet rset1=stmt1.executeQuery("SELECT count(*) FROM
    user_details_table" );
    while(rset1.next())
    int x=rset1.getInt(1);
    System.out.println("No.of Connected Users In UserDetails Table: " + x);
    }

Maybe you are looking for