JSP vs Javascript question

I'm confused. Does it make sense to use
Javascript in a JSP? I've just started using jsp
and i'm trying to get things straight in my head
thanks for any tips or advice
owen

Yes, if you want limit number of server query, it's very important.
for exemple, you can generate Javascript table contain your datas and use javascript to generate the page (using a .js file who stay on navigator file).
So you can make nice pages, with a lot of functions, but just send data on reload.
Users can create or modify datas on a dynamic form (generated on javascript, who only store changes on javascript table) and submit data to the server on command (so no server query when user create a line for exemple).
I think it's a good way to create rich UI without generate big html files.
regards.

Similar Messages

  • Jsp,servlet,bean question,please help

    The Tomcat Web server set up like this.......
    The directory structure is
    e:/sampleapp/WEB-INF/classes
    /lib
    And the web.xml is in the WEB-INF for the use of ay potential servlet.
    The basic understanding is that all the .java files go into the WEB-INF directory and the .class files go into the classes directory.
    All the .jsp files go into the sampleapp directory.Till here is correct I feel.
    Now for my qustion......
    I plan to use jsp,servlet and beans for a potential web application...,where do all these files go?,just the same as above or is there a difference.
    Hope that I have given a reasonable explaination to my question.
    Thanks for any replies
    AS

    All of your compiled servlet and java bean (java
    classes in general) will be placed into the following
    directory (under a directory structure matching the
    java package they are in):
    e:/sampleapp/WEB-INF/classesAll of your .jar files that are used as libraries (not
    your .jar files for applets):
    e:/sampleapp/WEB-INF/libAll of the rest of your JSP files, javascript files,
    HTML files, JAR files, images files, etc. will go into
    the following directory:
    e:/sampleappYou must make sure you put your sampleapp directory
    where tomcat can load it. Or use the admin tool to
    load it. If you make a .WAR file with a corresponding
    web.xml file in it, it will simplify loading it into
    tomcat. It also will help you do your servlet
    mappings, etc. I hope this helps.Thanks for your timely response.To add to it,let me tell you.
    The <b>bean</b> files are put into a package right,so they should be put into the WEB-INF/classes/<package name>
    What about The <b> servlet </b> files...... they are just put into the WEB-INF/classes/ directory????
    Kindly let me know.
    Thanks
    AS

  • Additional Pageflow - JavaScript Questions

    I was hoping someone (bea employee???) could answer a couple more JavaScript questions
    for me?? First one is how do I (can I) do something similar to what John Rohrlich
    (see below) suggested inside a netui-data:grid tag? Among other things that didn't
    workI tried this:
    <netui-data:anchorColumn action="deleteUsr" title="">
    <netui:anchor action="deleteUsr" onClick="return confirmDelete('user', {container.item.usr_nm}
    ); return false;">
    Drop
    <netui:parameter name="userToDrop" value="{container.item.usr_nm}" />
    </netui:anchor>
    </netui-data:anchorColumn>
    From this snippet you might be able to guess what my next question is. Is there
    a way to render a variable inside the onClick value? I have tried a number of
    things to no avail, stuff like:
    <netui-data:getData resultId="thisId" value="{container.item.userId}" />
    <netui:anchor action="dropUser" onClick="return confirmDelete('user', '<%=(String)pageContext.getAttribute("thisId");%>');
    return false;">
    BTW this is in a repeater I have else ware in my code. I would really like to
    convert everything to grids to get the sorting, filtering and paging capabilities.
    I would like to be able to pass the parameter to my JavaScript so the user has
    a little more info on what he is dropping - here is the script:
    function confirmDelete(){
    //arg 1 would be the record type i.e. "user"
    //arg 2 would be the key identifier i.e. "Fred"
    var question = "Are you sure you want to drop this record?";
    var argNum = confirmDelete.arguments.length;
    if (argNum == 1){
    question = "Are you sure you want to drop this "+confirmDelete.arguments[0]+"?";
    else if (argNum == 2){
    question = "Are you sure you want to drop the "+confirmDelete.arguments[0]+"
    "+confirmDelete.arguments[1]+"?";
    return confirm(question);
    Thanks,
    John
    "John Rohrlich" <[email protected]> wrote:
    John,
    If you want to put up a confirm dialog before calling an action from
    an
    anchor it is done as follows.
    Here is an example from code of mine that deletes a customer order, if
    the
    user confirms the delete. I pass the order id as a parameter.
    - john
    Here is the JavaScript -
    function confirmDelete() {
    if(confirm('Continue with order delete?'))
    return true;
    else
    return false;
    Here is a sample anchor tag -
    <netui:anchor action="requestToDeleteOrder" onClick="return
    confirmDelete(); return false;">
    Delete
    <netui:parameter name="orderId" value="{container.item.orderId}"/>
    </netui:anchor>

    Thanks Eddie, I looked at that reply when you gave it but it didn't give me enough
    to go on. You suggested:
    <netui-data:expressionColumn title="Show Alert" value="<a href='javascript:alert(12345);return
    false;> {container.item.customername}</a>" />
    I started a new thread after that one - What is the best way to call a pageflow
    action from JavaScript? Guess I was sort of beating around the bush on this. Can
    you see where I was going? If I use the method you describe above how do I call
    my dropUser pageflow action if the user confirms the drop in the java dialog?
    Thanks, John
    Eddie O'Neil <[email protected]> wrote:
    John--
    You might check an earlier response about this from a different thread.
    "Re: Confirmation dialog w/netui:anchor and netui-data:anchorColumn"
    on
    1/28/2004.
    It's possible to do though not intentional; the 8.1 grid wasn't
    really designed to do this.
    The NetUI team is certainly aware of the limitations with using this
    version of the grid and is working to address said limitations with a
    much improved tag set in v9. If you have additional feedback on
    features you'd like to see, please feel free to send them along --
    including your top 10 (or whatever!) reasons not to use the grid. :)
    In the meantime, depending on what you need to do, the repeater may
    suit your needs well, though you may need to do some work to implement
    sort / filter logic.
    Hope that helps.
    Eddie
    John H wrote:
    So what you are telling me is that a cant do somthing as simple aspop up a confirmation
    when using a grid? That really stinks if that is the case. I am thinkingI need
    to write up "Top ten reasons not to use a grid." Thanks for the repeatercode.
    "John Rohrlich" <[email protected]> wrote:
    John,
    The grid doesn't support event handlers like onClick but I have included
    code here to show you how to pass parameters to your javaScript event
    handler when using the repeater. Let me know if you have any questions
    about
    the code.
    Most of the code is standard repeater code. The interesting code is
    below
    (also see my code comments). I have also attached the full jsp fileand
    the
    jpf file you need to try my example.
    - john
    <script language="JavaScript">
    function confirmDelete(phrase) {
    if(confirm(phrase))
    return true;
    else
    return false;
    </script>
    <netui-data:repeater dataSource="{pageInput.orders}" defaultText="No
    orders">
    <netui-data:repeaterItem>
    <tr valign="top">
    <td>
    <netui:label value="{container.item.orderId}"
    defaultValue=" "></netui:label>
    </td>
    <!-- You can't bind data to onClick so you need to build
    a
    string. -->
    <!-- The string will be the function call with the
    parameters you are passing. -->
    <!-- Here is the building of the string -->
    <netui-data:getData resultId="orderId"
    value="{container.item.orderId}" />
    <%
    String somePhrase = "Do you want to delete item " +
    pageContext.getAttribute("orderId") + "?";
    String foo = "return confirmDelete(\'" + somePhrase+
    return false";
    %>
    <td>
    <netui:anchor action="requestToDeleteOrder"
    onClick="<%=foo%>" >
    Delete
    <netui:parameter name="orderId"
    value="{container.item.orderId}"/>
    </netui:anchor>
    </td>
    </tr>
    </netui-data:repeaterItem>
    "John H" <[email protected]> wrote in message
    news:[email protected]...
    I was hoping someone (bea employee???) could answer a couple moreJavaScript questions
    for me?? First one is how do I (can I) do something similar to whatJohn
    Rohrlich
    (see below) suggested inside a netui-data:grid tag? Among other thingsthat didn't
    workI tried this:
    <netui-data:anchorColumn action="deleteUsr" title="">
    <netui:anchor action="deleteUsr" onClick="return confirmDelete('user',{container.item.usr_nm}
    ); return false;">
    Drop
    <netui:parameter name="userToDrop" value="{container.item.usr_nm}"/>
    </netui:anchor>
    </netui-data:anchorColumn>
    From this snippet you might be able to guess what my next questionis. Is
    there
    a way to render a variable inside the onClick value? I have trieda
    number of
    things to no avail, stuff like:
    <netui-data:getData resultId="thisId" value="{container.item.userId}"/>
    <netui:anchor action="dropUser" onClick="return confirmDelete('user','<%=(String)pageContext.getAttribute("thisId");%>');
    return false;">
    BTW this is in a repeater I have else ware in my code. I would reallylike to
    convert everything to grids to get the sorting, filtering and pagingcapabilities.
    I would like to be able to pass the parameter to my JavaScript sothe
    user has
    a little more info on what he is dropping - here is the script:
    function confirmDelete(){
    //arg 1 would be the record type i.e. "user"
    //arg 2 would be the key identifier i.e. "Fred"
    var question = "Are you sure you want to drop this record?";
    var argNum = confirmDelete.arguments.length;
    if (argNum == 1){
    question = "Are you sure you want to drop this"+confirmDelete.arguments[0]+"?";
    else if (argNum == 2){
    question = "Are you sure you want to drop the"+confirmDelete.arguments[0]+"
    "+confirmDelete.arguments[1]+"?";
    return confirm(question);
    Thanks,
    John
    "John Rohrlich" <[email protected]> wrote:
    John,
    If you want to put up a confirm dialog before calling an action
    from
    an
    anchor it is done as follows.
    Here is an example from code of mine that deletes a customer order,if
    the
    user confirms the delete. I pass the order id as a parameter.
    - john
    Here is the JavaScript -
    function confirmDelete() {
    if(confirm('Continue with order delete?'))
    return true;
    else
    return false;
    Here is a sample anchor tag -
    <netui:anchor action="requestToDeleteOrder" onClick="return
    confirmDelete(); return false;">
    Delete
    <netui:parameter name="orderId" value="{container.item.orderId}"/>
    </netui:anchor>

  • JSP to Excel question

    Hi,
    I have a jsp page that renders data from a result set (queried from database).
    A button on this pages calls a 2nd page that I want to re-query and open excel with the data.
    This all works except that there are a number of blank likes at the top of the excel page, prior to my data. These relate to declatations at the top of my page. i.e
    <%@ page import="java.io.*" %>
    and
    <jsp:useBean id="AccountDetailsBean" class="com.xxx.yyy.zzz.AccountDetailsBean" scope="session" />
    This will give 2 blank lines. I assume that this is because they are essentially being treated as HTML comment lines.
    How can I avoid this? Can I declare these within the main JSP servlet?
    Thanks for any assistance.

    However, remember that the parameters in GET requests are logged in the
    server log so whatever information you send to the server via a GET, remains
    logged and available to whoever has access to your logs. Shouldn't be many,
    but should that information get to the people who run a log analyzer to get
    statistics on the server usage?
    POST is better because the parameters are sent in the body of the request
    and the body is not logged.
    SSL needs to be used in both cases.
    "Dror Avinun" <[email protected]> wrote in message
    news:3affe4b3$[email protected]..
    >
    All the SSL encryption is done in the socket layer and all of the HTTPcommunication
    is encrypted. This means that both the request (yout "GET" command) andresponse
    are secured.
    cheers,
    Dror
    "Asher Bitton" <[email protected]> wrote:
    Hi,
    I'm using https to call from an excel application to a weblogic jsp page,
    my question is whether the url that excel sends (for example:
    "https://mypc:7002/mydir/myfile.jsp?myvar1=val1&myvar2=val2")
    gets also encrypted\secured, what I'm interested to know is whether the
    parameters sent using the http "get" method are secure?
    Where can I find some information regarding the https implementation
    thanks.

  • Set jsp from javascript

    I have three "div" tags in index.jsp ,
    <div id='header'></div>
    <div id='body'></div>
    <div id='footer'></div>
    Now when window is loaded i want other jsp page to be set in the "body" div tag of index.jsp from javascript
    My javascript code
    function invokeJSP(){
    document.getElementById('body').innerHTML="<jsp:include page='test.jsp'>'";
    when I am including this code in <head > part of index.jsp its working the problem is if at all
    In test.jsp
    if i try to include this line
    <% = request.getParameter("name")%>
    its giving an error like "unterminated literal string" in javascript console
    Can anyone help me how to set the jsp from javascript
    Sorry for my bad english.This is the first time I am posting the forum
    thanks
    hema

    hi
    Thanks for the response
    but i have closed the tag in my program. Have u ever tried to invoke jsp from javascript in this way if it works plz help me.
    thanks hema

  • Jsp in javascript

    hi
    can we use jsp in javascript
    for eg:
    <script>
    if(flag)
    <% respone.sendRedirect("--"); %>
    </script>
    or is there any other way of doing this type of things
    this is only an example.
    thx
    -jay

    You can use JavaScript in a JSP. JavaScript usually runs on client. You can also use Java in a JSP. Here is sample code:
    <%@ page import="java.util.*" %>
    <%
    Calendar cal = Calendar.getInstance();
         int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
         int hourOfDay = cal.get(Calendar.HOUR_OF_DAY);
         int minuteOfHour = cal.get(Calendar.MINUTE);
         if (((dayOfWeek == 7) & (hourOfDay == 23) & (minuteOfHour > 29)) || ((dayOfWeek == 1) & (hourOfDay == 0) & (minuteOfHour < 31))) { %>  
    <jsp:forward page="file:///M:/Studio/projects/som/html/IC_0019.htm" />
    <% } %>

  • JSP language javascript

    What is the problem?
    <%@ page language="javascript" %>
    <%
    var i;
    for ( i=1; i<5; i++ )
    out.println("JSP whit JavaScript <br>");
    %>

    What is the problem?
    <%@ page language="javascript" %>
    <%
    var i;
    for ( i=1; i<5; i++ )
    out.println("JSP whit JavaScript <br>");
    %>The <% and %> tags indicate a Java scriptlet.
    "var" is JavaScript syntax, the rest is Java.
    out.println is a Java method.
    If you want to do your loop in JavaScript then it would
    be like this:
    <script>
    for ( var i = 1; i < 5; i++ )
    document.writeln("JSP whit JavaScript <br>");
    </script>

  • JSP/javascript question. Guru's please help.

    Need help.
    I know we can assign value of a JSP variable to a javascript variable. e.g. strJScriptvar = <%=strJSPvar%>;
    Is there a way we can go the other way, i.e. assigning a javascript variable value to a JSP variable?
    e.g. will it be valid <%strJSPvar=%>=strJScriptvar;
    If not, is there a direct way of assigning the value.
    Any help will be heavily appreciated.
    Thanks,
    Indrasish.

    Yeah, that's it. Remember that JSPs are compiled into servlets then sent as HTML to your browser. Once the page is sent to your browser, there is nothing else the "JSP" part of it can do. It's already been processed, done it's thing, and sent the results to your browser.
    Make sense?

  • WL vs. WL-express and JSP vs. javascript/SQL

    folks-
    i am trying to convince a certain party to
    disband a web-based job tracking system being
    written in ASP, javascript, html, css and SQL.
    it will be hosted on MS webserver running NT.
    i am trying to convince them to use JSP and
    WL express. i have done two years of EJB
    component work on weblogic, however, i have not
    done work with JSP or thin-clients. i was mostly
    business-logic.
    anyway i have some questions and need some
    direction. i already know JSP is better than
    ASP/javascript etc. because:
    * ASP is proprietary. ditto for VBscript
    * with an IDE creating JSP is easy and JSP
    automatically creates servlets which is way
    faster than by hand
    * JSP is JAVA based and hence benefits from
    all the portability pluses of JAVA
    but here are the more difficult questions:
    * why is WL express better than an MS
    web server? (not including WL market share
    and size. after all MS can claim that)
    * since WL express does not have an EJB
    container, how do you access the database?
    via JDBC? does one just have JDBC code
    floating around?
    * since there is no EJB container how does
    one separate presentation from logic from
    data access? this is a major downside of
    javascript, html, css and SQL etc.
    * if a web app grows beyond JSP with WL express
    into the need for an EJB container, i would
    think that most of the app needs to re-written
    as business-logic must be refactored into EJBs
    and all JDBC code will be replaced by container
    managed beans. this sounds a like a lot of
    rework.
    * isn't JSP slower than javascript as the
    servlet and hmtl code is bounced back and
    force across the network?
    with respect to architecture, scalability,
    and robustness what are the downsides to an
    MS webserver and non-JSP coding?

    * since WL express does not have an EJB
    container, how do you access the database?
    via JDBC? does one just have JDBC code
    floating around?
    Use JDO or an OR-mapper or embed JDBC into your own data access classes.
    * since there is no EJB container how does
    one separate presentation from logic from
    data access? this is a major downside of
    javascript, html, css and SQL etc.
    Presentation=JSP
    Logic=Servlet
    Data access=JDO or similar
    * if a web app grows beyond JSP with WL express
    into the need for an EJB container, i would
    think that most of the app needs to re-written
    as business-logic must be refactored into EJBs
    and all JDBC code will be replaced by container
    managed beans. this sounds a like a lot of
    rework.
    You should be able to tell up front if it a tx-intensive app that requires
    WLS.
    * isn't JSP slower than javascript as the
    servlet and hmtl code is bounced back and
    force across the network?
    They aren't exclusive. For dynamic pages, use Javascript on the front end,
    JSP on the back.
    * with respect to architecture, scalability,
    and robustness what are the downsides to an
    MS webserver and non-JSP coding?
    In the real world, and for most apps, while Java has the architectural edge,
    they both have similar scalability and similar robustness. MS gives you no
    choice though, and you rewrite every time they see a new buzzword. You can't
    leave MS-land without abandoning almost everything. You can leave WLS in a
    week if you have to.
    It's an investment. Invest wisely.
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    Clustering Weblogic? You're either using Coherence, or you should be!
    Download a Tangosol Coherence eval today at http://www.tangosol.com/
    "shane miller" <[email protected]> wrote in message
    news:[email protected]...
    folks-
    i am trying to convince a certain party to
    disband a web-based job tracking system being
    written in ASP, javascript, html, css and SQL.
    it will be hosted on MS webserver running NT.
    i am trying to convince them to use JSP and
    WL express. i have done two years of EJB
    component work on weblogic, however, i have not
    done work with JSP or thin-clients. i was mostly
    business-logic.
    anyway i have some questions and need some
    direction. i already know JSP is better than
    ASP/javascript etc. because:
    * ASP is proprietary. ditto for VBscript
    * with an IDE creating JSP is easy and JSP
    automatically creates servlets which is way
    faster than by hand
    * JSP is JAVA based and hence benefits from
    all the portability pluses of JAVA
    but here are the more difficult questions:
    * why is WL express better than an MS
    web server? (not including WL market share
    and size. after all MS can claim that)
    * since WL express does not have an EJB
    container, how do you access the database?
    via JDBC? does one just have JDBC code
    floating around?
    * since there is no EJB container how does
    one separate presentation from logic from
    data access? this is a major downside of
    javascript, html, css and SQL etc.
    * if a web app grows beyond JSP with WL express
    into the need for an EJB container, i would
    think that most of the app needs to re-written
    as business-logic must be refactored into EJBs
    and all JDBC code will be replaced by container
    managed beans. this sounds a like a lot of
    rework.
    * isn't JSP slower than javascript as the
    servlet and hmtl code is bounced back and
    force across the network?
    with respect to architecture, scalability,
    and robustness what are the downsides to an
    MS webserver and non-JSP coding?

  • Retrieving lists from other layer into a JSP page - Design Question

    Hi all,
    What should be a good design technique in order to allow a JSP page to present some list obtained from other layer of my application. I intend to leave only presentation logic in the JSP layer, while all data access will be in other layer.
    For example, I have a JSP page that will show the results of a SQL query originated from an entry form in other JSP page. Let's name them 'search.jsp' and 'result.jsp'
    I want that all JDBC access be done in some other layer.
    Question 1:
    What would be better for this task? A servlet or a bean? (A bean, I suppose?)
    Then this bean (?) would have to find some way to pass all the result set into this 'result.jsp'. I think it would be very poor design if I used some Data Object, because it would have to store all rows and pass them at once.
    I don't want, either, that the presentation (JSP) layer access directly the data access layer (JDBC, files...). This way, I don't want any JSP page accessing the Resultset object directly.
    Question 2:
    What do you think could be a good design technique?
    I thought of some intermediate layer that provided data objects and data access interfaces. I mean, as my data will come from different sources, like some database (JDBC), some Electronic Document Manager, I thought of having a common access interface, that would provide methods for accessing the resultsets. This could be even a java.util.Enumeration that has a hasMoreElements() method that could be implemented as the next() method from JDBC result sets and the nextElement() method that would actually bring the next row of data.
    This way the JSP layer would see only hasMoreElements() and nextElement() methods from the middle layer. On the other hand, the data layer would provide as many different implementations to this access interface (Enumeration?) as there were data sources (JDBC, Files, ...)
    Question 3:
    What do you think of this design?
    Question 4:
    Is there any flaw in my approach? Which?
    Question 5:
    Could you suggest other designs?
    I really thank you all, for any kind of answer. I actually use this design for development, however I've never seriously discussed it with someone... this is going to be of great value for me.
    Regards,
    Filipe Fedalto

    Well I saw you question and I'll tell you what I do.
    I have JSP's which post form data to servlets.
    The servlet then calls a factory to produce a ResultContainer (analagous to your lists) which is generated
    via JDBC, and/or request parameters etc...
    this provides a single point of reference and a "group" of containers (functions really) that can be produced and reused (same container different amount of data)
    I also have other static classes which can manipulate the data in the containers
    (such as add additional info to the items in the containers) before I forward the container (request attribute)
    to the JSP page
    Additionally I use Type safe constants for all my HTML form tag names (easier to change and ensure the same name is used everywhere when reading parameters) and again for item statuses
    and any other info I need to send along with the page (using Javascript to update the
    status to another type safe constant).
    I've found that using factories for ResultContainers is very worthwhile and allows you to implement additional servlets extremely quickly (mostly reusing containers that exist) and since the
    container is the same for all my JSPs (this may not be the case with you) I can implement JSP's
    very quickly as well (just change the view)
    btw I refrain from calling my ResultContainer a bean because it is not serializable
    I don't know if this will help but at least it gives me a forum to test my ideas
    Thanks

  • Validating forms in jsp using javaScript

    Hi all i'm trying to validate this form with javeScript. i was testing it with just the <input type=text name= file> first. it works but after the alert message it still posts to writeXML......
    i tried putting the fuction valid() after the <form> tag but it still posts it to writeXML.jsp.......can anyone help me please........What i want to do is make sure that something is typed in all the forms befor posting to writeXML..Thanx
    <html>
    <head> <title>Create MultipleChoice Questions</title> </head>
    <script language="JavaScript">
    function valid(form) {
         if(form.file.value == "")
         alert("Please enter the file name")
    </script>
    <body bgcolor="#cccccc">
    <% int count = 0;
    String number = request.getParameter("nOfq");
    int qNumber = Integer.parseInt(number); %>
    <form action="writeXML.jsp" method="POST">
    <center>
         <table bgcolor="silver" border="1" width="75%">
         <tr align="center"><td><b>Type in the Name of your Questionnaire here eg. BlackHistory.      Dont leave any spaces between letters</b><br>
         <textarea name="file" rows="1" cols="25"></textarea><br>
         </td></tr>
    <% for(int i=1;i<qNumber+1; i++) { %>
    <%count++;%>
         <tr align="center" bgcolor="#336699"><td><b>QUESTION <%= count %>: </b><br>
         </td></tr>
         <tr align="center"><td><b>ENTER QUESTION:</b><br>
         <textarea name=<%="questionText"+i%> rows="5" cols="65"></textarea><br>
         </td></tr>
         <tr align="center"><td><b>CHOICE 1:</b><br>
         <textarea name=<%="choice_1"+i%> rows="2" cols="50"></textarea><br>
         </td></tr>
         <tr align="center"><td><b>CHOICE 2:</b><br>
         <textarea name=<%="choice_2"+i%> rows="2" cols="50"></textarea><br>
         </td></tr>
         <tr align="center"><td><b>CHOICE 3:</b><br>
         <textarea name=<%="choice_3"+i%> rows="2" cols="50"></textarea><br>
         </td></tr>
         <tr align="center"><td><b>CHOICE 4:</b><br>
         <textarea name=<%="choice_4"+i%> rows="2" cols="50"></textarea><br><br><br>
         </td></tr>
         <tr align="center" bgcolor="#679995"><td><b>CORRECT ANSWER:</b><br>
         <textarea name=<%="cAnswer"+i%> rows="2" cols="50"></textarea><br><br><br>
         </td></tr>
    <% } %>
    <tr>
    <td align="center"><input type="submit" name="next" value="NEXTT" onClick="valid(this.form)">
    <td align="center"><input type="hidden" name="qCount" value="<%=count+1%>">
    </td></tr>
    </table>
    </center>
    </form>
    </body>
    </html>

    this Corrected code works perfectly
    <html>
    <head> <title>Create MultipleChoice Questions</title> </head>
    <script language="JavaScript">
    function valid(form) {
    if(form.file.value == ""){
    alert("Please enter the file name");
    frmValid.file.focus();     
    }else{
         frmValid.action="writeXML.jsp";
         frmValid.submit();
    </script>
    <body bgcolor="#cccccc">
    <% int count = 0;
    int qNumber=-1;
    String number = clearNull(request.getParameter("nOfq"));
    if(! number.equals(""))
    qNumber = Integer.parseInt(number);
    %>
    <form name="frmValid" method="POST" >
    <center>
    <table bgcolor="silver" border="1" width="75%">
    <tr align="center"><td><b>Type in the Name of your Questionnaire here eg. BlackHistory. Dont leave any spaces between letters</b><br>
    <textarea name="file" rows="1" cols="25"></textarea><br>
    </td></tr>
    <% for(int i=1;i<qNumber+1; i++) { %>
    <%count++;%>
    <tr align="center" bgcolor="#336699"><td><b>QUESTION <%= count %>: </b><br>
    </td></tr>
    <tr align="center"><td><b>ENTER QUESTION:</b><br>
    <textarea name=<%="questionText"+i%> rows="5" cols="65"></textarea><br>
    </td></tr>
    <tr align="center"><td><b>CHOICE 1:</b><br>
    <textarea name=<%="choice_1"+i%> rows="2" cols="50"></textarea><br>
    </td></tr>
    <tr align="center"><td><b>CHOICE 2:</b><br>
    <textarea name=<%="choice_2"+i%> rows="2" cols="50"></textarea><br>
    </td></tr>
    <tr align="center"><td><b>CHOICE 3:</b><br>
    <textarea name=<%="choice_3"+i%> rows="2" cols="50"></textarea><br>
    </td></tr>
    <tr align="center"><td><b>CHOICE 4:</b><br>
    <textarea name=<%="choice_4"+i%> rows="2" cols="50"></textarea><br><br><br>
    </td></tr>
    <tr align="center" bgcolor="#679995"><td><b>CORRECT ANSWER:</b><br>
    <textarea name=<%="cAnswer"+i%> rows="2" cols="50"></textarea><br><br><br>
    </td></tr>
    <% } %>
    <tr>
    <td align="center"><input type="submit" name="next" value="NEXTT" onClick="valid(this.form)">
    <td align="center"><input type="hidden" name="qCount" value="<%=count+1%>">
    </td></tr>
    </table>
    </center>
    </form>
    </body>
    </html>
    <%!
    private String clearNull( String sField ) {
    return ( sField == null ) ? "" : sField;
    %>

  • Creating a Survey - Novice Javascript Question

    Hello,
    I am extrememely new to Javascript.  I have been doing some research online and copy/pasting code to create the results I need.  I am trying to create an online survey in Dreamweaver in which users select buttons to answer questions and then the total results appear at the bottom of the survey.  So far this is what I have:
    http://sicolaconsulting.com/SurveyTest4.php
    The problem I have with this is that on each line, a user can select more than one box.  I don't want this so I thought radio buttons would be better.  I then came up with this:
    http://sicolaconsulting.com/SurveyTest3.php
    The problem with this is that with the function I am using, I can only get it to display the value of the first line.  I need it to calculate the sum of all the lines.
    Can you help me revise the script I have to get my desired result.
    Here is my code for the first page, followed by the code for the second page.  THANK YOU!
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <title>Survey</title>
    <style type="text/css">
    body,td,th {
              font-family: Tahoma, Geneva, sans-serif;
    </style>
    <link href="stylesheets/SCG_Styles.css" rel="stylesheet" type="text/css" />
    <title>Survey</title>
    <script type="text/javascript">
              function TotalPart1A() {
                        document.survey.Total1A.value = '';
                        var sum = 0;
                        for (i=0;i<document.survey.Part1A.length;i++) {
                          if (document.survey.Part1A[i].checked) {
                                    sum = sum + parseInt(document.survey.Part1A[i].value);
                        document.survey.Total1A.value = sum;
    </script>
    <link href="stylesheets/SCG_Styles.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <div id="wrapper"><br />
      <div id="survey-header"><strong>Purpose:</strong><br />
        The Learning Style Survey assesses your general approach to learning. <br />
        It does not predict your behavior, but it is a clear indication of your overall style preferences.<br />
        <br />
        <strong>Instructions:</strong><br />
        For each item circle the response that represents your approach. Complete all items. <br />
        There are eleven major activities representing twelve different aspects of your learning style. <br />
        When you read the statements, try to think about what you generally do when learning. <br />
        <br />
        <strong>Time:</strong><br />
        It takes about 30 minutes to complete the survey. Do not spend too much time on any item. Indicate your immediate response (or feeling) and move on to the next item. <br />
        <br />
        <strong>For each item, enter your immediate response:<br />
          0 = Never  1 = Rarely  2 = Sometimes  3 = Often  4 = Always</strong><br />
      </div>
              <div id="survey">
    <form name="survey">
              <div id="survey-section1">
                    <table class="survey-table" cellspacing="0" width="812">
                      <tr>
                        <td height="24" colspan="2" align="left" bgcolor="#CCCCCC"><strong>Part 1: How I Use My Physical Senses</strong></td>
                        <td height="24" align="center" bgcolor="#CCCCCC"><strong>1</strong></td>
                        <td height="24" align="center" bgcolor="#CCCCCC"><strong>2</strong></td>
                        <td height="24" align="center" bgcolor="#CCCCCC"><strong>3</strong></td>
                        <td height="24" align="center" bgcolor="#CCCCCC"><strong>4</strong></td>
                        </tr>
                      <tr>
                        <td width="31" height="27">1</td>
                        <td width="515" align="left">I remember something better if I write it down.</td>
                        <td width="60"><input type="checkbox" name="Part1A" value="1" onchange="TotalPart1A()"/></td>
                        <td width="60"><input type="checkbox" name="Part1A" value="2" onchange="TotalPart1A()"/></td>
                        <td width="60"><input type="checkbox" name="Part1A" value="3" onchange="TotalPart1A()"/></td>
                        <td width="60"><input type="checkbox" name="Part1A" value="4" onchange="TotalPart1A()"/></td>
                        </tr>
                      <tr>
                        <td width="31" bgcolor="#EAEAEA">2</td>
                        <td height="27" align="left" bgcolor="#EAEAEA"> I take detailed notes during lectures.</td>
                        <td bgcolor="#EAEAEA"><input type="checkbox" name="Part1A" value="1" onchange="TotalPart1A()"/></td>
                        <td bgcolor="#EAEAEA"><input type="checkbox" name="Part1A" value="2" onchange="TotalPart1A()"/></td>
                        <td bgcolor="#EAEAEA"><input type="checkbox" name="Part1A" value="3" onchange="TotalPart1A()"/></td>
                        <td bgcolor="#EAEAEA"><input type="checkbox" name="Part1A" value="4" onchange="TotalPart1A()"/></td>
                        </tr>
                      <tr>
                        <td>3</td>
                        <td height="27" align="left">When I listen, I visualize pictures, numbers, or words in my head.</td>
                        <td><input type="checkbox" name="Part1A" value="1" onchange="TotalPart1A()"/></td>
                        <td><input type="checkbox" name="Part1A" value="2" onchange="TotalPart1A()"/></td>
                        <td><input type="checkbox" name="Part1A" value="3" onchange="TotalPart1A()"/></td>
                        <td><input type="checkbox" name="Part1A" value="4" onchange="TotalPart1A()"/></td>
                        </tr>
                      <tr>
                        <td bgcolor="#EAEAEA">4</td>
                        <td height="27" align="left" bgcolor="#EAEAEA"> I prefer to learn with TV or video rather than other media. </td>
                        <td bgcolor="#EAEAEA"><input type="checkbox" name="Part1A" value="1" onchange="TotalPart1A()"/></td>
                        <td bgcolor="#EAEAEA"><input type="checkbox" name="Part1A" value="2" onchange="TotalPart1A()"/></td>
                        <td bgcolor="#EAEAEA"><input type="checkbox" name="Part1A" value="3" onchange="TotalPart1A()"/></td>
                        <td bgcolor="#EAEAEA"><input type="checkbox" name="Part1A" value="4" onchange="TotalPart1A()"/></td>
                        </tr>
                      <tr>
                        <td>5</td>
                        <td height="27" align="left"> I use color coding to help me as I learn to work.</td>
                        <td><input type="checkbox" name="Part1A" value="1" onchange="TotalPart1A()"/></td>
                        <td><input type="checkbox" name="Part1A" value="2" onchange="TotalPart1A()"/></td>
                        <td><input type="checkbox" name="Part1A" value="3" onchange="TotalPart1A()"/></td>
                        <td><input type="checkbox" name="Part1A" value="4" onchange="TotalPart1A()"/></td>
                        </tr>
                      <tr>
                        <td bgcolor="#EAEAEA">6</td>
                        <td height="27" align="left" bgcolor="#EAEAEA"> I need written directions for tasks.</td>
                        <td bgcolor="#EAEAEA"><input type="checkbox" name="Part1A" value="1" onchange="TotalPart1A()"/></td>
                        <td bgcolor="#EAEAEA"><input type="checkbox" name="Part1A" value="2" onchange="TotalPart1A()"/></td>
                        <td bgcolor="#EAEAEA"><input type="checkbox" name="Part1A" value="3" onchange="TotalPart1A()"/></td>
                        <td bgcolor="#EAEAEA"><input type="checkbox" name="Part1A" value="4" onchange="TotalPart1A()"/></td>
                        </tr>
                      <tr>
                        <td>7</td>
                        <td height="27" align="left"> I have to look at people to understand what they say.</td>
                        <td><input type="checkbox" name="Part1A" value="1" onchange="TotalPart1A()"/></td>
                        <td><input type="checkbox" name="Part1A" value="2" onchange="TotalPart1A()"/></td>
                        <td><input type="checkbox" name="Part1A" value="3" onchange="TotalPart1A()"/></td>
                        <td><input type="checkbox" name="Part1A" value="4" onchange="TotalPart1A()"/></td>
                        </tr>
                      <tr>
                        <td bgcolor="#EAEAEA">8</td>
                        <td height="27" align="left" bgcolor="#EAEAEA">I understand lecturers better when they write on the board.</td>
                        <td bgcolor="#EAEAEA"><input type="checkbox" name="Part1A" value="1" onchange="TotalPart1A()"/></td>
                        <td bgcolor="#EAEAEA"><input type="checkbox" name="Part1A" value="2" onchange="TotalPart1A()"/></td>
                        <td bgcolor="#EAEAEA"><input type="checkbox" name="Part1A" value="3" onchange="TotalPart1A()"/></td>
                        <td bgcolor="#EAEAEA"><input type="checkbox" name="Part1A" value="4" onchange="TotalPart1A()"/></td>
                        </tr>
                      <tr>
                        <td>9</td>
                        <td height="27" align="left">Charts, diagrams, and maps help me understand what someone says. </td>
                        <td><input type="checkbox" name="Part1A" value="1" onchange="TotalPart1A()"/></td>
                        <td><input type="checkbox" name="Part1A" value="2" onchange="TotalPart1A()"/></td>
                        <td><input type="checkbox" name="Part1A" value="3" onchange="TotalPart1A()"/></td>
                        <td><input type="checkbox" name="Part1A" value="4" onchange="TotalPart1A()"/></td>
                        </tr>
                      <tr>
                        <td bgcolor="#EAEAEA">10</td>
                        <td height="27" align="left" bgcolor="#EAEAEA">I remember people’s faces, but not their names. </td>
                        <td bgcolor="#EAEAEA"><input type="checkbox" name="Part1A" value="1" onchange="TotalPart1A()"/></td>
                        <td bgcolor="#EAEAEA"><input type="checkbox" name="Part1A" value="2" onchange="TotalPart1A()"/></td>
                        <td bgcolor="#EAEAEA"><input type="checkbox" name="Part1A" value="3" onchange="TotalPart1A()"/></td>
                        <td bgcolor="#EAEAEA"><input type="checkbox" name="Part1A" value="4" onchange="TotalPart1A()"/></td>
                        </tr>
                      <tr>
                        <td> </td>
                        <td height="27" align="right">A TOTAL: </td>
                        <td colspan="2"><input type="text" size="10" name="Total1A" value="0"/></td>
                        <td align="right"> </td>
                        <td> </td>
                        </tr>
                      <tr>
                        <td> </td>
                        <td height="27" align="right"> </td>
                        <td> </td>
                        <td> </td>
                        <td align="right"> </td>
                        <td> </td>
                        </tr>
                      </table>
    </form>
                </div>
              </div>
        </body>
        </html>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <title>Survey</title>
    <style type="text/css">
    body,td,th {
              font-family: Tahoma, Geneva, sans-serif;
    </style>
    <link href="stylesheets/SCG_Styles.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
              function TotalPart1A() {
                        document.survey.Total1A.value = '';
                        var sum = 0;
                        for (i=0;i<document.survey.radiogroup1A.length;i++) {
                          if (document.survey.radiogroup1A[i].checked) {
                                    sum = sum + parseInt(document.survey.radiogroup1A[i].value);
                        document.survey.Total1A.value = sum;
    </script>
    <link href="stylesheets/SCG_Styles.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <div id="wrapper"><br />
      <div id="survey-header"><strong>Purpose:</strong><br />
        The Learning Style Survey assesses your general approach to learning. <br />
        It does not predict your behavior, but it is a clear indication of your overall style preferences.<br />
        <br />
        <strong>Instructions:</strong><br />
        For each item circle the response that represents your approach. Complete all items. <br />
        There are eleven major activities representing twelve different aspects of your learning style. <br />
        When you read the statements, try to think about what you generally do when learning. <br />
        <br />
        <strong>Time:</strong><br />
        It takes about 30 minutes to complete the survey. Do not spend too much time on any item. Indicate your immediate response (or feeling) and move on to the next item. <br />
        <br />
        <strong>For each item, enter your immediate response:<br />
          0 = Never  1 = Rarely  2 = Sometimes  3 = Often  4 = Always</strong><br />
      </div>
      <div id="survey">
        <form name="survey" id="survey">
          <div id="survey-section1">
          <table class="survey-table" cellspacing="0" width="812">
            <tr>
              <td height="24" colspan="2" align="left" bgcolor="#CCCCCC"><strong>Part 1: How I Use My Physical Senses</strong></td>
              <td height="24" align="center" bgcolor="#CCCCCC"><strong>1</strong></td>
              <td height="24" align="center" bgcolor="#CCCCCC"><strong>2</strong></td>
              <td height="24" align="center" bgcolor="#CCCCCC"><strong>3</strong></td>
              <td height="24" align="center" bgcolor="#CCCCCC"><strong>4</strong></td>
            </tr>
            <tr>
              <td width="31" height="27">1</td>
              <td width="515" align="left">I remember something better if I write it down.</td>
              <td width="60"><input type="radio" name="radiogroup1A" value="1" onchange="TotalPart1A()"/></td>
              <td width="60"><input type="radio" name="radiogroup1A" value="2" onchange="TotalPart1A()"/></td>
              <td width="60"><input type="radio" name="radiogroup1A" value="3" onchange="TotalPart1A()"/></td>
              <td width="60"><input type="radio" name="radiogroup1A" value="4" onchange="TotalPart1A()"/></td>
            </tr>
            <tr>
              <td width="31" bgcolor="#EAEAEA">2</td>
              <td height="27" align="left" bgcolor="#EAEAEA"> I take detailed notes during lectures.</td>
              <td bgcolor="#EAEAEA"><input type="radio" name="radiogroup2A" value="1" onchange="TotalPart1A()"/></td>
              <td bgcolor="#EAEAEA"><input type="radio" name="radiogroup2A" value="2" onchange="TotalPart1A()"/></td>
              <td bgcolor="#EAEAEA"><input type="radio" name="radiogroup2A" value="3" onchange="TotalPart1A()"/></td>
              <td bgcolor="#EAEAEA"><input type="radio" name="radiogroup2A" value="4" onchange="TotalPart1A()"/></td>
            </tr>
            <tr>
              <td>3</td>
              <td height="27" align="left">When I listen, I visualize pictures, numbers, or words in my head.</td>
              <td><input type="radio" name="radiogroup3A" value="1" onchange="TotalPart1A()"/></td>
              <td><input type="radio" name="radiogroup3A" value="2" onchange="TotalPart1A()"/></td>
              <td><input type="radio" name="radiogroup3A" value="3" onchange="TotalPart1A()"/></td>
              <td><input type="radio" name="radiogroup3A" value="4" onchange="TotalPart1A()"/></td>
            </tr>
            <tr>
              <td bgcolor="#EAEAEA">4</td>
              <td height="27" align="left" bgcolor="#EAEAEA"> I prefer to learn with TV or video rather than other media. </td>
              <td bgcolor="#EAEAEA"><input type="radio" name="radiogroup4A" value="1" onchange="TotalPart1A()"/></td>
              <td bgcolor="#EAEAEA"><input type="radio" name="radiogroup4A" value="2" onchange="TotalPart1A()"/></td>
              <td bgcolor="#EAEAEA"><input type="radio" name="radiogroup4A" value="3" onchange="TotalPart1A()"/></td>
              <td bgcolor="#EAEAEA"><input type="radio" name="radiogroup4A" value="4" onchange="TotalPart1A()"/></td>
            </tr>
            <tr>
              <td>5</td>
              <td height="27" align="left"> I use color coding to help me as I learn to work.</td>
              <td><input type="radio" name="radiogroup5A" value="1" onchange="TotalPart1A()"/></td>
              <td><input type="radio" name="radiogroup5A" value="2" onchange="TotalPart1A()"/></td>
              <td><input type="radio" name="radiogroup5A" value="3" onchange="TotalPart1A()"/></td>
              <td><input type="radio" name="radiogroup5A" value="4" onchange="TotalPart1A()"/></td>
            </tr>
            <tr>
              <td bgcolor="#EAEAEA">6</td>
              <td height="27" align="left" bgcolor="#EAEAEA"> I need written directions for tasks.</td>
              <td bgcolor="#EAEAEA"><input type="radio" name="radiogroup6A" value="1" onchange="TotalPart1A()"/></td>
              <td bgcolor="#EAEAEA"><input type="radio" name="radiogroup6A" value="2" onchange="TotalPart1A()"/></td>
              <td bgcolor="#EAEAEA"><input type="radio" name="radiogroup6A" value="3" onchange="TotalPart1A()"/></td>
              <td bgcolor="#EAEAEA"><input type="radio" name="radiogroup6A" value="4" onchange="TotalPart1A()"/></td>
            </tr>
            <tr>
              <td>7</td>
              <td height="27" align="left"> I have to look at people to understand what they say.</td>
              <td><input type="radio" name="radiogroup7A" value="1" onchange="TotalPart1A()"/></td>
              <td><input type="radio" name="radiogroup7A" value="2" onchange="TotalPart1A()"/></td>
              <td><input type="radio" name="radiogroup7A" value="3" onchange="TotalPart1A()"/></td>
              <td><input type="radio" name="radiogroup7A" value="4" onchange="TotalPart1A()"/></td>
            </tr>
            <tr>
              <td bgcolor="#EAEAEA">8</td>
              <td height="27" align="left" bgcolor="#EAEAEA">I understand lecturers better when they write on the board.</td>
              <td bgcolor="#EAEAEA"><input type="radio" name="radiogroup8A" value="1" onchange="TotalPart1A()"/></td>
              <td bgcolor="#EAEAEA"><input type="radio" name="radiogroup8A" value="2" onchange="TotalPart1A()"/></td>
              <td bgcolor="#EAEAEA"><input type="radio" name="radiogroup8A" value="3" onchange="TotalPart1A()"/></td>
              <td bgcolor="#EAEAEA"><input type="radio" name="radiogroup8A" value="4" onchange="TotalPart1A()"/></td>
            </tr>
            <tr>
              <td>9</td>
              <td height="27" align="left">Charts, diagrams, and maps help me understand what someone says. </td>
              <td><input type="radio" name="radiogroup9A" value="1" onchange="TotalPart1A()"/></td>
              <td><input type="radio" name="radiogroup9A" value="2" onchange="TotalPart1A()"/></td>
              <td><input type="radio" name="radiogroup9A" value="3" onchange="TotalPart1A()"/></td>
              <td><input type="radio" name="radiogroup9A" value="4" onchange="TotalPart1A()"/></td>
            </tr>
            <tr>
              <td bgcolor="#EAEAEA">10</td>
              <td height="27" align="left" bgcolor="#EAEAEA">I remember people’s faces, but not their names. </td>
              <td bgcolor="#EAEAEA"><input type="radio" name="radiogroup10A" value="1" onchange="TotalPart1A()"/></td>
              <td bgcolor="#EAEAEA"><input type="radio" name="radiogroup10A" value="2" onchange="TotalPart1A()"/></td>
              <td bgcolor="#EAEAEA"><input type="radio" name="radiogroup10A" value="3" onchange="TotalPart1A()"/></td>
              <td bgcolor="#EAEAEA"><input type="radio" name="radiogroup10A" value="4" onchange="TotalPart1A()"/></td>
            </tr>
            <tr>
              <td> </td>
              <td height="27" align="right">A TOTAL: </td>
              <td colspan="2"><input type="text" size="10" name="Total1A" value="0"/></td>
              <td align="right"> </td>
              <td> </td>
            </tr>
            <tr>
              <td> </td>
              <td height="27" align="right"> </td>
              <td> </td>
              <td> </td>
              <td align="right"> </td>
              <td> </td>
            </tr>
          </table>
        </form>
      </div>
    </div>
    </body>
    </html>

    Hi Nancy,
    I've been away from this for a while and have picked it back up.  I tried your suggested code and I'm having problems getting it to work.  I created a file using the code you supplied for the survey here:
    view-source:http://www.littlechisel.com/clients/GreenSurvey/GreenSurvey.html
    It doesn't work so I know I'm missing something.  If you could advise me on this, it would be great.  Thanks! Here is the code as I have it:
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <script type="text/javascript">
    function calcscore() {
        var score = 0;
        $(".calc:checked").each(function() {
            score += parseInt($(this).val(), 10);
        $("input[name=sum]").val(score)
    $().ready(function() {
        $(".calc").change(function() {
            calcscore()
    </script>
    <link href="stylesheets/Survey.css" rel="stylesheet" type="text/css">
    </head>
    <body>
    <h1>jQuery Sum of Radio Fields</h1>
    <form action="">
    <h2>HOW GREEN ARE YOU?</h2>
    <p><strong>I walk/bicycle  to work/school. </strong><br>
    Yes
    <input class="calc" type="radio" name="radio1" value="10">
    No
    <input class="calc" type="radio" name="radio1" value="0">
    Sometimes
    <input class="calc" type="radio" name="radio1" value="5"></p>
    <p><strong>I buy  locally grown food. </strong><br>
    Yes
    <input class="calc" type="radio" name="radio2" value="10">
    No
    <input class="calc" type="radio" name="radio2" value="0">
    Sometimes
    <input class="calc" type="radio" name="radio2" value="5"></p>
    <p><strong>I recycle. </strong><br>
    Yes
    <input class="calc" type="radio" name="radio3" value="10">
    No
    <input class="calc" type="radio" name="radio3" value="0">
    Sometimes
    <input class="calc" type="radio" name="radio3" value="5"></p>
    <p><strong>I compost. </strong><br>
    Yes
    <input class="calc" type="radio" name="radio4" value="10">
    No
    <input class="calc" type="radio" name="radio4" value="0">
    Sometimes
    <input class="calc" type="radio" name="radio4" value="5"></p>
    <p>Total Green Score:
    <input type="text" name="sum">
    </p>
    </form>
    </body>
    </html>

  • How to access variables across JSP and JavaScript?

    Hi,
    I have some .js files and in those files, some of the methods need to access to the variables that I'd declare in the jsp files. How do I do it?
    Anne

    You can do it this way, but I'm not sure if this is what you had in mind.
    Say you had a java variable called XString. And you wanted to display
    the value of XString in a javascript Alert. Here's how:
    <html>
    <body>
    <% String XString = "Hi There!"; %>
    </body>
    <script language="javascript">
    alert("<%=XString%>");
    </html>Hope This Help,
    P.

  • Please help me...Javascript question

    Hi everyone,
    what i am trying to do is..
    EX:
    TABLE: EMP
    empno empname sal entered_by
    1 john 1000 user1
    I have a form on the table EMP.The users want to enter the same record again(because mutiple users enter the same record) but want an alert message when they hit the create button like.. Eg:
    when user2 is trying to enter this data..
    empno: 2 (generated by sequence)
    empname: john
    sal: 1000
    he wants to see an alert message like: THE Record is Already exists in the database which was entered by USER1 (But he can enter the same record)
    what i did is.. I have a javascript which calls the application process (PL/SQL) where it check whether the data entered is already there in the database and returns back an alert message like this:
    JAVASCRIPT:
    ==========
    <script language=javascript>
    function  f_insert_record()
            var get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=INSERT_RECORD',0);
            get.add('P2_EMPNAME',html_GetElement('P2_EMPNAME').value);
            get.add('P2_SAL',html_GetElement('P2_SAL').value);
            gReturn = get.get();
            var a = gReturn.split("|");
            if(gReturn)
                if (a.length > 0) {alert(a[0]);}
            else
                null;
    </script>APPLICATION_PROCESS
    ===================
    DECLARE
       l_error   VARCHAR2 (4000);
       V_NAME VARCHAR2(1000);
       V_MSPR_ID NUMBER(15);
       I NUMBER;
       V_MYNUM STRING_OBJ := STRING_OBJ();
    BEGIN
      FOR C1 IN (SELECT DISTINCT entered_by ENTERED_BY_USER_NM 
    from emp 
    WHERE  
      empname = :P2_EMPNAME
      AND sal  = :P2_SAL
      ) LOOP
        V_MYNUM.EXTEND;
        V_MYNUM(V_MYNUM.COUNT) := C1.ENTERED_BY_USER_NM;
      END LOOP;
      V_NAME := NULL;
      l_error := NULL;
      FOR I IN V_MYNUM.FIRST..V_MYNUM.LAST LOOP
        --dbms_output.put_line(V_MYNUM(I));
        V_NAME := V_NAME || '   ' || V_MYNUM(I);
      END LOOP;
      IF V_NAME IS NOT NULL THEN
        l_error := 'The record already exists in the database which was created by '||V_NAME;
      END IF; 
      HTP.PRN(l_error);
    END;everything works fine...when i have a ONBLUR event on the SALARY field.
    But i want the same thing to be achieved with the ONCLICK event on the CREATE button (Template based button).
    The code i have shown over here is just an example...But the requirement is the same..Multiple Users can enter the same record but they want to see an alert message like this record was entered by USER1,USER2.
    The only think i am not able to figure out is the ONCLICK event on that create button.
    I tried like this Target: URL
    javaScript:(f_insert_record();doSubmit('CREATE');)
    I am not getting the alert message.
    Please help me to solve this
    thanks
    phani

    damn it! Those little quotation marks.....
    I already did figure it out awhile after I posted my question
    Thanks anyway!

  • How to pass values from JSTL to JSP or Javascript ?

    Hi All,
    Is it possible to share or use the variables which are declared are used by JSTL in JSP expression or scriplet code and in Java Script.
    Example:
    This Works:
    <fmt:set var="test" value="JSTL" />
    <fmt:out value="${test}" />
    But, this gives error:
    <% out.println(test) %>
    And passing the value of variable 'test' to Java Script code also gives error.
    How to use JSTL variables in JSP and in Javascript ?
    Yours,
    Sankar.B

    <% out.println(pageContext.getAttribute("test") %>
    If your tags use a different scope then you'll nee to access them accordingly e.g this will work
    <c:set var="test" value="JSTL" scope="session" />
    <c:out value="${test}" />
    <% out.println(session.getAttribute("test")); %>

Maybe you are looking for

  • XML to CSV routine using XSLT.  Oracle bugs?

    I'm trying to write some XSLT so that I can apply it to any given XML using  XMLTransform to generate a flattened CSV structure.  My input can be any XML document, with any number of nested levels so the structure isn't known to the XSLT.  I'm fairly

  • Import, Eject and Refesh not working on iTunes 7.6

    I updated to iTunes 7.6 today and now i iTunes won't import and eject cd automatically. I now have to eject cd manually, i then have to close itunes and re-open it as it doesnt auto refresh when a new cd is put in. it worked ok before i updated. I ha

  • WPC Content inside Dynamic Navigaiton

    Hi Experts, I have a requirement, where I need to display WPC content inside Dynamic Navigation. We are using NW Portal 7.4 SP 8 I am using the below approach to display WPC content in content area as well as dynamic navigaiton. With the below mentio

  • PC suite need dial pad

    Hello I would like to have in PCsuite dial panel for dialing numbers not in my contact list. I use PC Suite as follows: Phone + set BH-700 + the computer I accept calls simply pressing the button on dialog window which gives out PC Suite, therefore I

  • What is the best software for the Panoroma feature?

    Does anyone have any tips on what software they use, and how to set up a camera for this feature at all please? Cheers