Passing parameter from Servlet to javascript in JSP. Very Urgent - 5 jukes!

Well my servlet will retrieve questions from database.
Then the player will answer the question in the JSP and submit the answer to the servlet to process.
Each time an answer is submitted, or a "Next Question" button is clicked, the countdown time will restart.
And will reload the page with a new question.
So how can i do that?
This is my servlet, JSP, javascript
=====================================================================
* Interacts with the player depending on his types of selection and output them
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class GameQuestionServlet extends HttpServlet
     String sSQL = null;
     String sCategory = null;
     String paramName = null;
     User userObject = null;
     Questions gameQsObj = new Questions();
     HttpSession session;
     int cnt = -1;
     int score = 0;
     boolean connected = false;
     public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
          session = request.getSession(false);
          //System.out.println("Testing Score:" + score);
          if(connected == true)
               Questions object = (Questions)gameQsObj.getQsList().elementAt(cnt);
               System.out.println("\n" + object.sAns1);
               System.out.println(object.sAns2);
               System.out.println(object.sAns3 + "\n");
               Enumeration enum = request.getParameterNames();
               while(enum.hasMoreElements())
                    paramName = (String)enum.nextElement();
                    if(paramName.equals("mcq"))
                         System.out.println(request.getParameter("mcq"));
                         score = Integer.parseInt(userObject.score.trim());
                         System.out.println("Player old score: " + score);
                         //Check to see if the selected answer matches the correct answer
                         if((object.sCorrect).equals(request.getParameter("mcq")))
                              score = score + 10;
                         else
                              if((object.sCorrect).equals(request.getParameter("mcq")))
                                   score = score + 10;     
                              else
                                   if((object.sCorrect).equals(request.getParameter("mcq")))
                                        score = score + 10;     
                                   else
                                        score = score - 10;     
          System.out.println("Player current score: " + score);
          else     //will only go into this once
               userObject = (User)session.getAttribute("user");
               System.out.println("\n"+userObject.nric);
               System.out.println(userObject.name);
               System.out.println(userObject.password);
               System.out.println(userObject.email);
               System.out.println(userObject.score+"\n");
               //depending on user selection
               sCategory = request.getParameter("qsCategory");
               sSQL = "SELECT * FROM " + sCategory;
               gameQsObj.getQuestions(sSQL, sCategory);
               score = Integer.parseInt(userObject.score);
               connected = true;
          System.out.println("Connected:" + connected);
          System.out.println("Before:" + userObject.score);
          cnt = cnt + 1; //increment to retrieve next question
          userObject.score = Integer.toString(score);     
          System.out.println("After:" + userObject.score);
          if(cnt < 3) //setting for the number of questions per game.
               //request.setAttribute("qsCnt", cnt); //count of the question number
               request.setAttribute("aQs", gameQsObj.getQsList().elementAt(cnt));
               System.out.println(request.getAttribute("aQs"));
               System.out.println("This is question number: "+ cnt);
               getServletConfig().getServletContext().getRequestDispatcher("/JSP/PlayGame.jsp").forward(request, response);
          else
               //forward to the result page     
     public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
          doPost(request, response);
<%@ page import="Questions" %>
<HTML>
     <HEAD>
          <TITLE>Play Game</TITLE>
          <SCRIPT LANGUAGE="JavaScript">
               var refreshinterval=10
               var displaycountdown="yes"
               var starttime
               var nowtime
               var reloadseconds=0
               var secondssinceloaded=0
               function starttime() {
                    starttime=new Date()
                    starttime=starttime.getTime()
                    countdown()
               function countdown() {
                    nowtime= new Date()
                    nowtime=nowtime.getTime()
                    secondssinceloaded=(nowtime-starttime)/1000
                    reloadseconds=Math.round(refreshinterval-secondssinceloaded)
                    if (refreshinterval>=secondssinceloaded) {
               var timer=setTimeout("countdown()",1000)
                         if (displaycountdown=="yes") {
                              window.status="You have "+reloadseconds+ " second before timeout"
               else {
                    hide();
               clearTimeout(timer)
                         //window.location.reload(true)
               function hide() {
                    //hidelayer
                    if(gameLayers.style.visibility == "visible"){
                         gameLayers.style.visibility = "hidden"
                         oops.style.visibility = "show"
               window.onload=starttime
          </SCRIPT>
     </HEAD>
     <BODY>
          <FORM METHOD="post" ACTION="http://localhost:8080/Java_Assignment2/servlet/GameQuestionServlet">
               <DIV ID="oops" STYLE="position:absolute; left:300px; top:30px; width:120px; height:150px; z-index:2; visibility:hidden">
                    Oops! 30 seconds time up!!! <BR><BR>
                    <INPUT TYPE="submit" VALUE="Next Question">
                    <INPUT TYPE="hidden" NAME="nextQs" VALUE="Next Question">
               </DIV>
               <DIV ID="gameLayers" STYLE="position:absolute; left:300px; top:30px; width:120px; height:150px; z-index:3; visibility:show">
               <TABLE BORDER="0">
                    <TR>
                         <TH><BIG>Questions:</BIG></TH>
                    </TR>
<%
                    Questions aQsObj = (Questions)request.getAttribute("aQs");
                    String aQsBody = aQsObj.sQs;
                    String aQsAns1 = aQsObj.sAns1;
                    String aQsAns2 = aQsObj.sAns2;
                    String aQsAns3 = aQsObj.sAns3;
%>
                    <TR>
                         <TD><B><%= aQsBody%></B></TD>
                    </TR>
                    <TR>
                         <TD>
                              <SELECT SIZE="3" NAME="mcq">
                                   <OPTION SELECTED><%= aQsAns1 %></OPTION>
                                   <OPTION><%= aQsAns2 %></OPTION>
                                   <OPTION><%= aQsAns3 %></OPTION>
                              </SELECT><BR><BR>
                         </TD>
                    </TR>
                    <TR>
                         <TD>
                              <INPUT TYPE="submit" VALUE="Submit Your Answer">
                              <INPUT TYPE="hidden" NAME="submitAns" VALUE="Submit Your Answer">
                         </TD>
                    </TR>
               </TABLE>
               </DIV>
          </FORM>
     </BODY>
</HTML>
This must be answered before 28th of september.
Please help. It is indeed very urgent.

this is just a skeleton code.. alot of stuff is not here..
<FORM name = "form1" action="../servlet/wateverSevlet>
<input type="text" name="searchStr" size="40">
<INPUT type="hidden" id=answer name=answer size=7>
<input type="button" name="button" value="Submit Answer" onClick="javascript:submitCheck(document.form1.searchStr.value);">
<input type="button" name="button" value="Skip Question" onClick="javascript:submitCheck('skip');">
</form>
<SCRIPT LANGUAGE="JavaScript">
function submitCheck(str)
  form1.answer.value = str
  form1.submit()
</script>i assuming you are submitting it to the same servlet regardless of whether the user clicks the skip question or the submit question button.

Similar Messages

  • Passing parameter from servlet to Javascript url

    Hi all,
    I want to pass the value of a selected option box in servlet as a parameter to a url in JavaScript.
    my java script code is :
    out.println("function reloadform() { ");
    out.println("alert('aacat');");
    out.println("location.href = 'http://localhost:8080/examples/servlet/frec1?aacatt=aacat';");
    out.println("}");
    and servlet code is :
    out.println("<td bgcolor=#F2F9FF> <select name=aacat size=1 style=font-size: 8pt; color: #666666; font-family: Verdana; border: 1 solid #666666 onChange= 'reloadform();'>");
    while (ra.next()==true) {
    String mycat=ra.getString("acat");
    String myasc=ra.getString("ascode");
    out.println(mycat+"<br>");
         out.println("<option value='"+mycat+"'><font face=verdana size=1>"+mycat+"</font></option>");
    Can anyone suggest me something on this ? Any Code reference will be highly appreciated.
    Thanks for any help in advance.
    savdeep.

    Please take care post the code in proper format...
    regarding the solution.. try something like..
    <select name=aacat size=1 style=font-size: 8pt; color: #666666; font-family: Verdana; border: 1 solid #666666 onChange= 'reloadform(this.options[this.selectedIndex].value);'>");also change the javascript code suitably

  • Pass data from servlet to jsp using sendRedirect

    Hi,
    I am passing data from servlet to jsp using forward method of request dispatcher but as it doesn't change the url it is creating problems. When ever user refreshes the screen(browser refresh) it's re-loading both servlet and jsp, which i don't want to happen. I want only the jsp to be reloaded.
    Can I pass data from servlet to jsp using sendRedirect in this case. I also want to pass some values from servlet to jsp but without using query string. I want to set some attributes and send to jsp just like we do for forward method of request dispatcher.
    Is there any way i can send data using attributes(without using query string) using sendRedirect? Please let me know

    sendRedirect is meant as a true redirect. meaning
    you can use it to redirect to urls not in your
    context....with forward you couldn't pass information
    to jsps/servlets outside your own context.Actually, you can:
    getServletContext().getContext("/other").getRequestDispatcher("/path/to/servlet").forward(request, response)I think the issue here is that the OP would like to have RequestDispatcher.forward() also update the address in the client's browser. That's not possible, AFAIK. By the time the request is forwarded, the browser has already determined the URL of the servlet, and the only I know of way to have the browser change the URL to the forwarded Servlet/JSP is to send a Location: header (i.e. sendRedirect()). Remember that server-side dispatching is transparent to the client. Maybe there's some tricky stuff you can do with JavaScript to change the address in the address bar without reloading the page?
    Brian

  • Pass Parameter to Servlet

    How can i pass parameter from a JSP form (depends on what user chooses from a select box to a Servlet.
    I need to call multiple query based on what parameter choosen and display the result in table view.
    Example :
    1. User select choice1 from JSP form -> Servlet : call query Select * from Table1 where cond = choice1;
    2. User select choice2 from JSP form -> Servlet : call query Select * from Table1 where cond = choice2;
    Any sample code?
    Thanks for any help.

    Thanks melondck.
    I have this Servlet which i want it to run queries and display results in table format. I know there's something wrong with the code. But i am new to Servlet/Java. Thanks for anyone who point me the mistakes. Thanks.
    <code>
    package mypackage;
    import java.sql.*;
    import javax.servlet.http.*;
    import java.io.*;
    import javax.servlet.*;
    public class DisplayServlet extends HttpServlet {
    public void doGet(HttpServletRequest req, HttpServletResponse rsp)
    throws ServletException, IOException {
    rsp.setContentType("text/html");
    String url="jdbc:mysql://localhost/smdb";
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    String query;
    ServletOutputStream out = rsp.getOutputStream();
    PrintWriter out1 = rsp.getWriter();
    String answer = req.getParameter("answer");
    out1.println("<html>");
    out1.println("<head><title> Inventory: </title></head>");
    out1.println("<body>");
    if (answer == null) {
    StringBuffer action = HttpUtils.getRequestURL(req);
    out1.println("<form action=\"" + action + "\" method=\"POST\">\n");
    out1.println("<p><b>Please select:</b></p>");
    out1.println("<p><input type=\"radio\" name=\"answer\" " +
    "value=\"A\" /> Display All <br />");
    out1.println(" <input type=\"radio\" name=\"answer\" " +
    "value=\"B\" /> Device <br />");
    out1.println(" <input type=\"radio\" name=\"answer\" " +
    "value=\"C\" /> Manufacturer <br />");
    out1.println(" <input type=\"radio\" name=\"answer\" " +
    "value=\"D\" /> Location <br />");
    out1.println(" <input type=\"submit\" value=\"Submit\" /></p>");
    out1.println("</form>");
    } else {
    try {
    Class.forName("com.mysql.jdbc.Driver");
    con = DriverManager.getConnection (url, "user", "mypass");
    stmt = con.createStatement();
    if (answer.equals("A")) {
    query = "SELECT Device, LocFloor FROM Inventory";
    esleif (answer.equals("B)) {
    query = "SELECT Device, LocFloor FROM Inventory where ....";
    ResultSet result = stmt.executeQuery(query);
    //Display the result set in a HTML table
    out.println("<HTML><HEAD><TITLE>List</TITLE></HEAD>");
    out.println("<BODY>");
    out.println("<FORM NAME='form' ");
    out.println("METHOD='GET'><TABLE BORDER='1' CELLSPACING='2' CELLPADDING='2'>");
    out.println("<TR><TH></TH><TH>Device Type</TH><TH>Floor</TH></TR>");
    while(result.next()) {
    String type = result.getString("Device");
    String flr = result.getString("LocFloor");
    out.println("<TD>" + type + "</TD>");
    out.println("<TD>" + flr + "</TD>");
    catch(ClassNotFoundException e) {
    out.println("Could not load database driver: " + e.getMessage());
    catch(SQLException e) {
    out.println("SQLException caught: " + e.getMessage());
    finally {
    //close the database connection.
    try {
    if (con != null) con.close();
    catch (SQLException e) {}
    out.println("</body></html>");
    </code>

  • How to pass parameter from 1 stored procedure to another stored procedure inside crystal report

    Hi
    I have several stored procedure in my Crystal Report. I am wondering if it is possible for me to pass a parameter to one of the stored procedure and to use the result of that stored procedure E.g. CustomerCode. To another 2 stored procedure to generate the report dynamically?
    I have 3 stored procedure
    The 1st one is used to gather information and process the calculation
    another 2 stored procedure is used for generate the graph and both of them required to take 2 parameters. The 1st stored procedure will require 1 parameter (E.G. Reference Code) and will return a set of information including the data that could be use on the other 2 stored procedures.
    After I added these 2 stored procedure, it requires me to pass 3 parameters to the report. I would like to know if I could only pass the Reference Code for stored procedure 1 and use it to retrieve the information for the other 2 parameter?
    Thanks in advance
    Chi

    Hi Chi
    To pass parameter from 1 stored procedure to another stored procedure, you will have to create sub report. In your case you will have to create 2 sub reports for 2nd and 3rd stored procedure and link those sub reports with the main report using Reference Code field in order to pass the values.
    After creating the report when you will refresh the report, it will ask 4 parameters, one parameter for main report, one for the first subreport and two for second subreport to fetch the data correctly.
    Regards
    Poonam Thorat.

  • How to pass parameter from form6i to report6i

    when i passed parameter from form6i to report6i, while previewing report the data was not displaying only fields heading was displaying, but in report6i there is a parameter form thru that it was displaying data, but thru form6i to report6i it was not. Please kindly help me and give me the some sample or example of it.
    Thanks
    Best regards
    Zaheer

    ADD_PARAMETER(pl_id,'P_SCRIPT',TEXT_PARAMETER,:b1.script);

  • Master-detail relationship - passing parameter from form to form

    Hello.
    I have a question about master detail relationship.
    In first form we have master-detail relationship.
    Example on dept, emp tables:
    We query dept (master), so we can get one or many emp (detail) records. Then we have a third table - tasks. Tasks table (detail) can have many records for one employee.
    Tasks table is in another form, which is called with call_form built_in. So we pass a parameter from master to detail - parameter empno. Because of that, we can only see tasks for one employee and can't navigate to another employee. This is normal.
    Now comes the question.
    Is it possible to call a form (with tasks table) with deptno parameter (so we can navigate through all employees with that department), but first show employee that was last used in first form?
    Example of our goal.
    Master: deptno = 20
    Detail: navigate to JONES employee
    Call new form (tasks)
    Tasks for JONES employee are first shown
    Can navigate to another employee - without requery
    Is this possible?
    If we pass deptno parameter, we can navigate through all employees - but must navigate to the employee we last used in first form.
    If we pass empno parameter to second form, we see last used employee but cannot navigate to another employee without requery.
    Hope you understand my problem.
    Thanks.

    Hi
    yes you can pass parameter from one form to another.
    In your master detail form set the trigger when-new-instance and there define the global variable like
    :GLOBAL.G_CIRCLE_ID := NULL;
    and in your task table set the trigger when-new-instance and there define the global variable like and also write this code
    :GLOBAL.G_DIVISION_ID := NULL;
    IF :GLOBAL.G_CIRCLE_ID IS NOT NULL THEN
         GO_BLOCK('DIVISION');
         SET_BLOCK_PROPERTY('DIVISION',DEFAULT_WHERE,'CIRCLE_ID ='||''''||:GLOBAL.G_CIRCLE_ID||'''');
         EXECUTE_QUERY;
    END IF;
    :GLOBAL.G_CIRCLE_ID := NULL;
    now you maintain your trigger according your need.
    Regards,

  • Problem while passing parameter from report to report.

    Hi
    I'm using forms and reports 10g, hava a problem while passing the parameter from reports to report.
    i'm using srw.set_hyperlink to call report from report.
    i have created a key value in the cgicmd.dat file called
    faccre802005-2006: report=faccre80 destype=cache desformat=pdf userid=<userid/passwd@cs> server=<servername>
    Now in the format trigger i'm using this key value
    function BTN_DEBITFormatTrigger return boolean is
    temp varchar2(5000);
    IP_ADDRESS VARCHAR2(50);
    SERVER_NAME VARCHAR2(10);
    L_ACCT_CODE VARCHAR2(14);
    begin
    SELECT MAST_INT_DESC,MAST_USER_PGM_ID INTO IP_ADDRESS,SERVER_NAME FROM MAST_INT_INFO WHERE MAST_INT_ID='VISHWA';
    temp := IP_ADDRESS||'?faccre80'||:P_FIN_YEAR||'+server='||server_name;
    temp :=temp ||'+'||'P_PREVIOUS_CODE='''||:ACCT_CODE||''''||'+'||'P_COMPANY_CODE='''||:P_COMPANY_CODE||'''';
    temp :=temp ||'+'|| 'P_FROM_DATE='''||TO_CHAR(:P_FROM_DATE,'DD-MON-RRRR')||''''||'+'|| 'P_TO_DATE='''||TO_CHAR(:P_TO_DATE,'DD-MON-RRRR')||''''||'+'||'P_TRUST_CODE='''|| :P_TRUST_CODE||'''';
    temp :=temp ||'+'|| 'P_UNIT_CODE='''||:P_UNIT_CODE||''''||'+'||' P_FIN_YEAR='''||:P_FIN_YEAR||'''';
    temp :=temp ||'+'|| 'P_LEVEL='''||:P_LEVEL||''''||'+'||'P_HEADER='''||replace(:P_HEADER,' ','%20')||''''||'+'||'P_FORMAT='''||:P_FORMAT||'''';
    SRW.Set_Hyperlink(temp);
    END;
    return (TRUE);
    end;
    Report is coming but not the expected result because parmaeters are not coming from first report to second report.
    If i dont use cgicmd file userid and password are displyed in the URL.
    Pl tell me how to pass parameter from one report to another.
    thanks and regards

    Hi
    I got the solution.
    I forgot to add %* at end of the KEY value.

  • How can I pass parameter from report to form?

    Hi :)
    Now I try to build conference room like this by using form
    and report. And i design that when users click at group report
    then i'll show page that contain questions report and add
    question form. And question form and report must receive the
    same parameter from group report.
    First Problem: is I don't know how group report send the
    same parameter to question report and add question report at the
    same time. And is it possible??? If not please suggest me what
    should I do???
    Second Problem: is I don't know how can I pass parameter from
    report to form. I don't know the way to do it.
    Please tell me!!! Please...
    I look forward to hearing from all of you.
    Thank You.

    One way is to create a link based on that form and attach that
    link with the report. Through links you can pass parameters

  • How to   Pass Parameter from BIP  to Dashboard  Report

    Hi,
    Parameter from BIP to Dashboard Report
    If I select BIP report paremeter should pass value to dashboard report
    thanks in advance.
    CHEERS ,
    Jel

    Hi Saichand,
    I hav gone through above link its passing values from Dashboard prompt to BIP report only..
    just i need like reverse (if i click on BIP report value then it should pass that value to Dashboard reports) in this this case how to pass parameter from BIP to dashboard report
    Thanks in advance
    Cheers,
    Jel

  • Hw to pass parameter from report to forms

    Dear Friends,
    I m working on Forms n Reports 6i,
    I m running report n passing parameter from the forms now the requirement is that if report run successfully it shuld give the msg otherwise give an user define error msg.
    Hw do i pass any parameter from report to form for acknowledgment.
    Thanking yours
    Chandan

    Hi Rajat,
    using run_product built in i can pass parameter from forms to reports but hw can i get some parameter value from reports to forms as mentioned earlier my post
    Thanking Yours,
    Chandan

  • Passing Parameter from URL to Web Forms - Oracle 10 Application Server

    Hi All -
    I want to pass parameter from a URL to 10g Oracle Web Forms - Oracle Application Server 10.1.2
    http://server1/forms/frmservlet?config=SATWEB_SSO&otherparams=username_sso=BABUS
    How to receive this 'username_sso' value inside my forms application ?
    Created a Parameter in the same name as URL parameter 'username_sso' in forms but didn't receive the value. I want to know how to receive the value of this parameter within forms from URL.
    Thanks - Suresh

    Try this,
    1. Create a parameter in the formsweb.cfg (say username_sso) under default section ( or you can create it in your own config section)
    2. Add the username_sso in otherparams parameter as username_sso=%username_sso%
    3. Add this username_sso parameter in your form.
    4. Run the form as
    http://<machine>:<port>.....?form=blahblah....&otherparams=username_sso=scott
    Regards,
    Arun

  • Not able to pass parameter from one fragment to another fragment in another taskFlow

    Hi,
    I'm trying to pass parameter from one fragment to another fragment and want to print the parameter value in second fragment.
    i have inputtext in first frag---
    first fragment belongs to one taskflow1 and this taskflow1 i had darg and drop to one mainPage.
    Under taskflow1 itself i drag and drop one taskflow call activity and on top of that i drag and drop another bounded taskflow as taskflow2
    under taskflow2 i have one fragment as fragment2and in that i have one outputtext field, now here i want to print the value from fragment1--inputtextfield value
    to achive this i had tried many ways but somewhere doing mistake please explain step by step.
    Thanks
    Mahesh

    In addition you need to tell us your jdev version!
    Can you elaborate on your use case a be more?
    On which event this should happen?
    In general contextual events should allow you to implement this, however, as I don't understand the use case, I find it hard to help.
    Timo

  • Passing parameter from workitem to bsp page

    Hi,
    is it possible to pass parameter from workitem to bsp page and also vice versa?

    SAP_WAPI_READ_CONTAINER function works well.but i need to pass a parameter to workitem container.
    what i am trying to do is;
    1-get data by using sap_wapi_read_container
    2-change data
    3-send changed data back to workitem
    my problem is in third step.I am using SAP_WAPI_WRITE_CONTAINER. but it doesnt work.After execution the FM return_code set to 1.
    Do u know how to set a variable in workitem?

  • Passing Parameter from javascript to Servlet

    hi,
    I have 2 list boxes in my Jsp page and values for these list boxes are preloaded . These things are to be carried out using javascript onload() function.
    So now i want to pass the selected parameters from both the list boxes to servlet and have to display the corresponding resulting datas in same JSP page. if i submit the form then values selelcted by the user will reset because the form has onload() function. then i thought hidden field will solve my problem. but its giving error like nullpointer exception.
    so please tell me how to achive this.

    When you right a new Option(...) line in javascript, there are three parameters you can give:
    Option("text", "value", selected);
    How you make use of this depends on how you move from the servlet back to the JSP.
    So for example, if you are doing a response.sendRedirect in the servlet, you will either have to add a parameter back to the url you are re-directing to, or add the value to the session. (I like the session method myself... hides it from the user)
    //in servlet
      public void doGet(...)... {
        String country = request.getParameter("country");
        String state = request.getParameter("state");
        //... Do Stuff ...
        HttpSession session session = request.getSession();
        session.setAttribute("country", country);
        session.setAttribute("state", state);
        String sendTo = response.encodeRedirectURL("theForm.jsp");
        response.sendRedirect(sendTo);
      //... The JSP might look like this now...
      //Get the selected values from the session:
      <%
        String countrySelected = (String)session.getAttribute("country");
        String stateSelected = (String)session.getAttribute("state");
      %>
      <html>
      <head>
      <script type="text/javascript">
      /* Use this to store the values for states in JavaScript */
      var state2DArray;
      /* Javascript function to set up values for the states  and countries */
      function initSelects() {
        <%
          /* This is JSP scriptlet code to get the country list that we need... */
          List countries = (List)application.getAttribute("countryList");
        %>
        countrySelect = document.form.country;
        <%
          /* This is JSP scriptlet code to loop through the countries and assign
           * values as needed.  We will break out of scriptlets to print out
           * the javascript needed to assign values to the countrySelect and to
           * the state2DArray
          int countryCount = countries.size();
        %>
        state2DArray=new Array(<%=countryCount+1%>);
          state2DArray[0] = new Array(1);
          state2DArray[0][0]="--Select A State--";
        <%
          for (int co = 1; co <= countryCount; co++) {
            Country country = (Country)countries.get(co-1);
            List stateList = country.getStates();
            int stateCount = stateList.size();
        %>
        //Now we add a true/false if the country should be selected...
        countrySelect.options[<%=co%>] = new Option("<%=country.getName()%>","<%=country.getId()%>",
                                                    <%= (country.getId() == countrySelected)%>);
        state2DArray[<%=co%>] = new Array(<%=stateCount+1%>);
        state2DArray[<%=co%>][0] = "--Select A State--";
        <%
            for (int st = 1; st <= stateCount; st++) {
              String stateName = (String)stateList.get(st-1);
        %>
        state2DArray[<%=co%>][<%=st%>] = "<%=stateName%>";
        //We are going to call the fillInStates now at the end of initSelects so the initial
        //values are passed on to the states...
        fillInStates(countrySelect);
        <%
        %>
      function fillInStates(countrySelect) {
        selectedCountry = countrySelect.selectedIndex;
        stateCount = state2DArray[selectedCountry].length;
        stateSelect = document.form.state;
        stateSelect.options.length = 0;
        for (state = 0; state < stateCount; state++) {
          //Again add true/false if it should be selected...
          stateSelect.options[state] = new Option(state2DArray[selectedCountry][state], state2DArray[selectedCountry][state],
                                                  <%= (stateSelected == state2DArray[selectedCountry][state]) %>);
    </script>
      </head>
      <body onload="initSelects()">
      <form name="form" id="form" action="#" method="get">
        <select name="country" id="country" onchange="fillInStates(this);">
          <option value="">--Select A Country--</option>
        </select>
        <select name="state" id="state">
          <option value="">--Select a State--</option>
        </select>
      </form>
      </body>
    </html>

Maybe you are looking for

  • My Game Center doesn't stop loading, what am I going to do?

    I need help asap. Thanks.

  • Unable to find Logical Volume manager in OEL6

    Hi Guru's, I am new to Linux. I have installed OEL6 in my windows box with Virtual Box. After logging in i don't see the Logical Volume manager and Network option under Administration menu too. I tried to install lvm-1.0.8-14.x86_64.rpm (downloaded f

  • How do you Stop Booting to System Recovery

    I have a ThinkeCentre that boots to System Recovery Options.   The hard drive was full and I cleared space and ran repairs.  If I hit Enter on the BIOS splash screen I get the boot menu and hit F11 then the system boots the OS (Windows 7) and works f

  • JAVA iso9660/UDF file system creation

    Is there a class or utility in JAVA that will allow the creation of an iso9660 file system for CD's and/or the creation of a UDF file system for DVD's? I am looking for such a class to incorporate into an applcation that is currently under developmen

  • Inbound Proxy created as Synchronous

    Hello, How do I determine the mode (synchronous/asynchronous) when I create a proxy?  I am trying to create an asynchronous inbound proxy and when I hit "generate" in SPROXY I get a synchronous proxy. Thanks, Matt