HELP!!!!! JSP and Java Script

Hi,
I have a JSP file that I need to create 3 drop lists (choice list). If one of these 3 choice lists is selected, then the other 2 need to deselected and disabled. I need help with the code.
Do I use JavaScript or Java? Below is the html code. I would really appreciate any help on this.
Thanks,
BK
<!--
Refer to the directory gary/reportingstd/getReqs.jsp to see how to get the value from the
choice list and other fields.
-->
<html>
<head><title>New Window Example</title>
<STYLE TYPE="text/css" >
td { font-size: 11px }
th { font-size: 11px }
body { background-color: #666666 }
</STYLE>
<SCRIPT>
/* When press CANCEL button, the dialog box disappears. */
     function Closer()
          window.close();
     function checkForm()
     var f = document.queryForm;
* Checks if an account number is entered. If not, an error message dialog pops up
* to the user.
* Checks if a business unit was chosen. If not, an error message dialog pops up
* to the user.
     buChoice = f.buList.selectedIndex;
          if (f.buList.options[buChoice].value == "")
               alert("Please choose a business unit.");
               f.buList.focus();
               f.toDate.select();
               return false;
     * This <code>statusMsg()</code>is to give the user feedback while data is being entered by
     * creating a status message. This script lets you modify what is displayed in this bar,
     * giving you the ability to send messages to the user while he interacts with filling out
     * the fields.Status Messages are the phrases you see in the status bar at the bottom of a
     * window or dialog.
     * For instance: For the account number text field, as long as the cursor is in this text
     * field of Account #, there's a message at the bottom of the dialog box informing, " Enter
     * only numeric characters."
     * @param msgType
     * @ mesage the data structure to store the messages sent to the users
     function statusMsg(msgType)
var message = "";
if (msgType == "integer")
message = "Enter numeric characters.";
if (msgType == "integerDate")
message = "between 1990 and 2010";
if (msgType == "ListBU")
message = "Choose which BU?";
if (msgType == "ListMonth")
message = "Choose a month."
window.defaultStatus = message;
window.status = message;
</script>
</head>
<body onFocus="statusMsg('')">
<FORM NAME= "queryForm" onSubmit = "return checkForm()" ACTION="Welcome.html">
<TABLE Border="0" cellspacing="2" cellpadding="4">
<TR>     
<TD ALIGN=left>Company Code:</TD>
<TD WIDTH="20%"><SELECT Name=choiceMonths1 size=1 onFocus="statusMsg('ListMonth')">
<option value="" selected>
<OPTION Value="01">01
<OPTION Value="02"> 02
<OPTION Value="03"> 03
<OPTION Value="04"> 04
<OPTION Value="05"> 05
<OPTION Value="06"> 06
</SELECT></TD>
     <TR>
     <TD ALIGN=left>RegionID:</TD>
     <TD><select name=buList onFocus="statusMsg('ListBU')"> // onChange = "selectionMade()"
     <option value="" selected>
     <option value=Norht ALIGN="left">North
     <option value=East ALIGN="left">East
          <option value=South ALIGN="left">South
     <option value ALIGN="left">North</select></TD></TR>
<TR>
     <TD ALIGN=left>Business Unit ID:</TD>
     <TD><select name=buList onFocus="statusMsg('ListBU')"> // onChange = "selectionMade()"
     <option value="" selected>
     <option value=TBR ALIGN="left">TBR
     <option value=BAL ALIGN="left">BAL
     <option value ALIGN="left">ABH</select></TD></TR>
</TR></TABLE>
<TABLE>
<tr>
<TD><INPUT TYPE=submit Value=Submit></TD>
<TD><INPUT TYPE=button NAME=btnClose VALUE=Cancel SIZE=20 ALIGN= center onClick="Closer()"></TD>
     <TD><input type=reset VALUE= Clear Query SIZE=20 ALIGN= right></TD></TR></TABLE>
</FORM>
</BODY>
</html>

What i've done in the past in this same situation is to use radio buttons alongside my dropdown lists. Whenever a radio button is selected, the corresponding dropdown list is enabled, and the other lists are all disabled. Not too hard to implement in Javascript either. Use an onClick() and set the other fields to disabled, using document.form.field.disabled = true. (and obviously, set the one you want to disabled = false). But obviously, you're still going to want to know which one to retrieve later, right? Use a hidden tag and in the same Javascript onClick, you can dynamically set the variable to whatever you want. Here's a pretty compact example using 2 fields
function enable(field)
     if(field == "firstName")
          document.myForm.firstName.disabled = false;
          document.myForm.lastName.disabled = true;
          document.myForm.searchBy.value = "firstName"
     else
          document.myForm.firstName.disabled = true;
          document.myForm.lastName.disabled = false;
          document.myForm.searchBy.value = "lastName"
}Or something like that. Yeah, I know it's not the greatest javascript in the world, but i was just simplifying things to give an example. Hope this helps somewhat :)
Simon

Similar Messages

  • Tree View through JSP and Java Script

    Hi,
    I am looking for code or ideas of a Tree Structure as shown in in the left side frame of admin console of Sun App server 7 on the browser. I need to create a tree structure which will work on the browser like it works on the Sun App Server 7 admin console. If you had any idea or code, please share with me. I would like to have some idea before I start building it. The tree will be build from the database. So any database design is also helpful. I am planning to have that tree using JSP and EJB.
    Please help. If you are not clear what I am looking for, then please drop a line in this forum, so that I can explain it fine.
    Thanks in advance.
    Amit

    You can use the JSP Tree Tag I have developed. This helps you both structuring the tree model itself + it takes care of displaying the tree in a nice way. You can change all HTML code used to display the tree. Also you can build trees dynamically instead of just displaying static trees. Take a look at it here:
    http://www.jenkov.dk/projects/treetag/treetag.jsp
    Kind Regards,
    Jakob Jenkov

  • Need flash player 8 and java script enabled to play videos on ipad, need help please.

    need flash player 8 and java script enabled on my ipad in order to view videos.  please help.

    iPads do not directly support Flash.
    You can look for Flash Browsers in the App store for some options to try. Support is not 100%, but maybe one may work for you.  Browsers like Puffin, Skyfire, Photon etc...
    IPads do fully support JavaScript.  Just make sure its turned on under Settings->Safari->Advanced->JavaScript.
    If you require Java, which is completely different to JavaScript, again there are some browsers in the App store that support it.  Search for "Java browsers" in the store.

  • JSP and Java Servelets, What do I need to get started?

    What do I have to download in order to start using JSP and Java Servelets? How do I test the codes after I've written something? Anyone?

    Right and you can download tomcat server from http://jakarta.apache.org/
    and do not forget to set java home path in tomcat.See it's documentation formore help on site itself.
    To test your codes for jsp put all your jsp,html,image and other resource files in tomcat's webaps's root directory.
    Put all your java class files of beans if used and servlet's class files in root's webinf's class directory.
    It will make sense to try very easy programs if u r a begineer .After starting the server post setting the java home path .(you can start it in bin directory's startup.bat file)
    All the best
    Ashish

  • How to Call a JSP from Java Script

    Hi,
    I want to call a jsp from Java Script.
    I am having IntelliJ IDEA 4.5 (IDE) and weblogic server.
    should i do anything on web.xml,weblogic.xml
    I have written one jsp, Java script.
    I want to call a jsp from Java script

    function submitf(){
    document.xyz.action ='ReportSave.jsp';
    document.xyz.method='POST';
    document.xyz.submit();
    <form name='xyz'>
    <input type='text' name='text1'>
    <input type='text' name='text2'>
    <input type='button' name='xx' value='submit' onclick= submitf()>
    </form>
    Is this what u want???
    Regards,
    RAHUL

  • Problem with JSP and Java Servlet Web Application....

    Hi every body....
    I av developed a web based application with java (jsp and Java Servlets)....
    that was working fine on Lane and Local Host....
    But when i upload on internet with unix package my servlets and Java Beans are not working .....
    also not access database which i developed on My Sql....
    M using cpanel support on web server
    Plz gave me solution...
    Thanx looking forward Adnan

    You need to elaborate "not working" in developer's perspective instead of in user's perspective.

  • Help,JSP and SERVLETS!

    hello:
    i've downloaded ECLIPSE 3.2,TOMCAT 5.5 .
    i tried to build simples examples o servlets but i failed could you please tell me how to proceed?i'm new at this plus i've got a project to do with all this so plz can you give some links to go,i tried but no links was clear.
    i've got to give to my professor an examples executed (servlets,jsp)
    thank you

    HISSO wrote:
    i wil give up on talking about stupid gossip
    you must act professional and i you can't help it's ok
    so plz i juste want help
    i'm so busy finishing my studies
    when it comes to talk about development with tomcat and eclipse together i'm new so i need some advices,so plz let's be serious!
    i'm working hard to finish my project!Try to communicate less like a monkey with electrodes attached to it's genitals. This means stop using words like "plz" and write "please" instead.
    If you want specific help with a specific problem then you should ask a specific question. "help, JSP and SERVLETS" is not a specific question. And you should also note that if your specific question is about Tomcat specifically or Eclipse specifically then you are in the wrong place to begin with.
    So do you want to try again?

  • I need to apply for a job but I'm told I need to enable cookies and java script, how do I do that?  I can't find it in system preferences

    I need to apply for a job but I'm told I need to enable cookies and java script, how do I do that?  I can't find it in system preferences
    I just updated to the new operating system which i'm starting to think was a bad idea, because it reset all my settings and I don't know how to fix them.

    so when I go to safari>preferences>security>uncheck box labled enable java script  links on webpages don't work and pictures and links son't want to appear on websites.  this made it so webpages don't want to work past loading the content in text format.  I have to check enable java script to go the webpages to work right so images and links work again but when I try to apply for this job the error message pops up saying I need to enable cookies and java script.
    SO I GUESS MY QUESTION IS IF JAVA SCRIPT IS ALREADY ENABLED HOW TO I ENABLE COOKIES?

  • Where can I download the last version that allows images and java script to be turned off?

    Due to my often slow connection I must have the option to turn off "automatically download images" and Java script. Firefox 23 does not have those options. Where can I download version 22 or whatever the latest version is that allowed these options?
    Thanks

    The Quickimage add-on doesn't work well at all, it gets stuck in the image off mode and will not switch back even after rebooting Firefox. Version 23.0 of Firefox is also very slow on my computer.
    I really need to find an older version of Firefox. Any idea where to download version 22 or earlier?

  • Need flash player 8  and java script

    why i try to open a videos from mac tube why is it showing i need a flash player 8+ and java script .

    iPads do not directly support Flash.
    You can look for Flash Browsers in the App store for some options to try. Support is not 100%, but maybe one may work for you.  Browsers like Puffin, Skyfire, Photon etc...
    IPads do fully support JavaScript.  Just make sure its turned on under Settings->Safari->Advanced->JavaScript.
    If you require Java, which is completely different to JavaScript, again there are some browsers in the App store that support it.  Search for "Java browsers" in the store.

  • Problem in the jsp, jstl and java script.

    Hi Friends,
    I am having one jsp which allows user(Could you please refer to code which is written in my jsp) to enter his username and password i want to get the password in the same jsp and want it to be passed to the custom tag without sending request to the server.Please give me an idea.Thanks in advance.
    This is the text field which allows a password.
    <INPUT type="password" name="password" size="10" maxlength="29" onblur="chkpwd()" onfocus="this.autocomplete=false" >
    and this is the anchor tag which refers as LOGIN BUTTON
    <IMG height=19 src="images/submit1.gif" width=106 border=0>
    when user clicks on LOGIN BUTTON i am calling one javascript function LOGIN(PASSWORD:) to check the validation if the validation is success then i want to get the password in the same function which is entered .
    This is ok i can get the password by "document.formName.password.value" then i need to pass this value to the jstl tag which is our own tag as shown below.
    <prefix:tagname value="PASSWORD which is having in the javascript variable".
    Please help me .
    Quick reply is thankfull.
    Edited by: bharathpolanki on Apr 20, 2008 1:55 AM
    Edited by: bharathpolanki on Apr 20, 2008 2:55 AM

    that's correct. You can use the below code for AJAX request.
    <script type="text/javascript">
    var httpObject = getHTTPObject();
    //create XMLHttpRequest object
    function getHTTPObject() {     
         var xmlhttp;
         if (window.XMLHttpRequest) // if Mozilla, Safari etc
              xmlhttp = new XMLHttpRequest();
         else if (window.ActiveXObject){ // if IE
              try {
                   xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
              catch ( e ){
                   try{
                        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                   catch ( e ){}
         return xmlhttp;
    //define the function to send the request
    function sendRequest(){
        var currDesc = document.getElementById("description").value;
        var URL =  "manageMaintAction.do"; //action mapping in your struts-config
        var queryString = "currDesc="+escape(currDesc); //get the currDesc value in your action class like request.getParameter("currDesc")
        httpObject.open( "Post", URL, true );
        httpObject.onreadystatechange = cbFn;
        httpObject.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded");
        httpObject.send(queryString);
    //callback fn
    function cbFn() {
        if (httpObject.readyState == 4)
             if (httpObject.status == 200)
              var result = httpObject.responseText;
              alert(result);
    </script>

  • Need Help Badly on Shopping Cart Using JSP And Java Servlet

    Hi All,
    This is the 1st time i am trying to create a shopping cart using JSP and Servlet.
    I have read through a few acticles but i still do not get the whole idea of how it works.
    Please guide me as i need help very badly.
    Thanks.
    This is one of the jsp page which displays the category of products user would like to buy : Products.jsp
    <html>
    <head>
    <title>Purchase Order</title>
    </head>
    <body topmargin="30">
    <table border="0" width="100%" id="table1" cellpadding="2">
         <tr>
              <td bgcolor="#990000" width="96">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
              Code</font></b></td>
              <td bgcolor="#990000" width="260">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
              Description </font></b></td>
              <td bgcolor="#990000" width="130">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">Brand
              </font></b></td>
              <td bgcolor="#990000" width="146">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">UOM
              </font></b></td>
              <td bgcolor="#990000" width="57">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">Unit<br>
              Price </font></b></td>
              <td bgcolor="#990000" width="62">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
              Carton<br>
              Price </font></b></td>
              <td bgcolor="#990000" width="36">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
              Qty</font></b></td>
              <td bgcolor="#990000" width="65">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">Add<br>
              To Cart</font></b></td>
         </tr>
    <tr>
    <td align="center" width="96" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">123</font>
    </td>
    <td align="center" width="260" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">Tom Yam</font>
    </td>
    <td align="center" width="130" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">Nissin</font>
    </td>
    <td align="center" width="146" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">12 x 10's</font>
    </td>
    <td align="center" width="57" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">$3.85</font>
    </td>
    <td align="center" width="62" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">$46.2</font>
    </td>
    <td align="center" width="36" bgcolor="#CCCCCC">
    <!--webbot bot="Validation" S-Data-Type="Integer" S-Number-Separators="x" -->
    <p align="center"><input type="Integer" name="Q10005" size="1"></p>
    </td>
    <td align="center" width="65" bgcolor="#CCCCCC">
    <p><input type="checkbox" name="checkbox" value="123"></p>
    </tr>
    <tr>
    </table>
    <table border="0" width="100%" id="table2">
         <tr>
              <td>
              <div align="right">          
                   <input type="hidden" name="hAction" value="AddToCart"/> 
              <input type=submit name="submit" value="Add To Cart"/>                     
    </div>
    </td>
         </tr>
    </table>
    </body>
    </html>
    After user has make his selection by entering the qty and ticking on the check box, he would click the "Add To Cart" button ... and this would call my servlet : AddToAddControlSerlvet.java
    import javax.servlet.http.*;
    import javax.servlet.*;
    import java.io.*;
    import java.util.*;
    import java.util.ArrayList;
    public class AddToCartControlServlet extends HttpServlet
         public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException
              String action = req.getParameter("hAction");
              if (action.equals("AddToCart"))
                   addToCart(req,res);
         public void addToCart(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
              try
                   String url = "";
                   String[] addList = req.getParameterValues("checkbox");
                   HttpSession sess = req.getSession(true);
                   //String sessionID = sess.getId();
                   DBClass dbClass = new DBClass();
                   ArrayList cartList = new ArrayList();
                   for (int i = 0; i < addList.length; i++)
                        String productCode = (String)addList;
                        int qty = Integer.parseInt(req.getParameter("Q"+productCode));
                        Products product = dbClass.getProductDetail(productCode);
                        double totalUnitAmt = qty * product.getUnitPrice();
                        double totalCartonAmt = qty * product.getCartonPrice();
                        Order order = new Order(product.getProductCode(),product.getProductDesc(),product.getBrandName(),product.getUom(),qty,product.getUnitPrice(),product.getCartonPrice(),totalUnitAmt,totalCartonAmt);
                        cartList.add(order);
                   sess.setAttribute("cartList", cartList);
                   url = "/Cart/CartDetails.jsp";
                   ServletContext sc = getServletContext();
                   RequestDispatcher rd = sc.getRequestDispatcher(url);
                   rd.forward(req, res);
              catch (Exception e)
                   System.out.println(e);
    From here, i would get the list of items which user has selected and add to the cartList, then i would direct the user to CartDetails.jsp which displayed the items user has selected.
    From there, user would be able to remove or to continue shopping by selecting other category.
    How i do store all the items user has selected ... everytime he would wan to view his cart ...
    As i would be calling from jsp to servlet .. or jsp to servlet ... and i do not know how i should go about in creating the shopping cart.

    Hi !
    Yon can use a data structure as vector and store the items selected by the user into the vector . Keep the vector in session using session object , so the user can access the entire shopping cart from anywhere in the application .
    Then , you can change the cart accordingly .
    Hope this works.
    Cheers ,
    Pranav

  • Yelp is not working properly, and I have been advised to enable cookies and Java Script. I have been trying for 1 hour using suggestions that don't work. Help.

    Someone suggested to go to firefox > options> content > and then there is supposed to be a button that enables Java Script. It is not there. Where did it go, please? The cookies problem I have no idea how to address. Have not gotten past the Java Script problem yet. I have updated Java many, many times in the past couple of months at the suggestion of Avast.

    You can check on the <b>about:config</b> page if the javascript.enabled pref is set to true.
    *http://kb.mozillazine.org/about:config
    You can try basic steps like these in case of issues with web pages:
    Reload web page(s) and bypass the cache to refresh possibly outdated or corrupted files.
    *Hold down the Shift key and left-click the Reload button
    *Press "Ctrl + F5" or press "Ctrl + Shift + R" (Windows,Linux)
    *Press "Command + Shift + R" (Mac)
    Clear the cache and the cookies from websites that cause problems.
    "Clear the Cache":
    *Firefox/Tools > Options > Advanced > Network > Cached Web Content: "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Firefox/Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe Mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • How can I change between JSP and Java in the page language attribute

    Does any one know the answer to this? I am trying to Switch between the 2 in the middle of the page. I want to include a file that uses <%@ page language = "JAVA" %> but the main mage uses Java Script. How can I switch it for this one file. I can't find the answer anywhere. Thanks for your time, and please help me. Also can some one post a good link for Session Tracking. I can't find much good information on that. Thanks again.
    Eagles757(JAY)

    Wow this didn't make sense in so many ways. It's truly bordering on nonsense. I think it's written in English.
    <%@ page language="Java" %>This is optional. JSPs don't use any language other than Java. This is known as a JSP Directive. This line will be processed by the JSP/Servlet engine, and you won't see it in your output. If JSP ever supported a language other than Java, this would be where you would change it.
    <script type="text/javascript">
    <!--
    // -->
    </script>You can include a block like this in your JSP file. The JSP/Servlet engine will not process this script block at all (unless you include JSP <% %> tags somewhere in there, in which case they will be processed before the response is sent back to the web browser). This script block is where JavaScript goes. This code will be executed on the client's browser.
    This is about as clear as I can make things given how muddled your question is. Please ensure you understand the basic differences between JSP, Java, JavaScript, HTML, Servlet engine, web browser before proceeding. Understand what code executes where, and in what order.
    Brian

  • What's the relationship between JSP and Java?

    hi,dear friends here.......^_^ I'm a graphic/web designer,
    cause the needed of internet web design, I started to learn html and Java server page.But I never have experience of JAVA programs. It's kind of hard for me to know and use JSP now.Should i need to learn Java first? Or can anyone tell me what's the good way for me to
    learn JSP?
    I also want to learn how do make a web page as the first page of java.sun.com about "Industry News ".
    Thanks !!grace from Taipei,Taiwan

    Hi! JSPs allow Java code together with HTML in one document. The servlet engine "compiles" a JSP into a servlet prior to executing it. So, one must know Java prior to dealing with JSPs.
    IMVHO, "Thinking In Java" by Bruce Eckel is a very good book for introduction to Java. You can download the electronic version at no charge from http://www.bruceeckel.com.
    After you get a good handle on Java, "Professional Java Server Programming" (Wrox Press) can give you good information on servlets and JSPs, along with some other related topics.
    Hope this helps!
    Cheers!

Maybe you are looking for

  • A problem about filter data in RPD by Roles

    Dear All, I face a serious problem. How I set the filter in RPD if there are several member I dont want to receive in different Generation? Assume I want receive A, B in Gen4, Accounts. C in Gen5, Accounts. And D, E, D in Gen6, Accounts? I tried to s

  • Question about abap/heaplimit

    Hi, This is related to NW04 on AIX and Oracle 10.2. I want to find out that how often the WP is restarting. It is based on either disp/wp_auto_restart or heaplimit parameter. The help.sap.com link as follows - To determine how many work processes are

  • WRT350N and a Sony SMP-N100 media player

    My network consists of the WRT350N with wired ethernet to mainframe PC, two wireless laptops, and a Sony Network Media Player(SMP-N100) which is also wireless and connected to a TV. I can access internet services like Netflix and it's working fine, b

  • Latest version of Cool Edit/ Audition to BUY regularly?

    Hello Au community, I'm not too crazy about buying a monthly subscription to an "app". Yeah, I'm old. Used to use Cool Edit when it was new and would love to have an updated version of that. Which is the latest version of CE/ Audition/ whatever that

  • Should I buy an X-Fi if I dont have good speake

    I already have an HD onboard sound chips, on my nForce 680i SLi motherboard. I also have the Creative Inspire 2200 2. speaker system. Would I really be able to tell the difference between the X-Fi and even an ordinary onboard sound chip, let alone th