Results 1 to 7 of 7
  1. #1
    newto is offline Member
    Join Date
    May 2010
    Posts
    17
    Rep Power
    0

    Default Redirect to jsp page based upon combobox selection

    Hi,
    I have an jsp page.Based upon the selection of combo box I want to redirect to another jsp page, on clicking the submit button.

    But my javascript code did not get executed.

    jsp---

    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">



    <html>
    <head>
    <title>Java Script use</title>
    <meta http-equiv="Content-Type" content="text/html;">
    <script language="javaScript" type="text/javascript" src="test.js"></script>

    </head>
    <body bgcolor="#c5e7e0" >

    <table border="0" cellspacing="6" cellpadding="3">
    <thead>
    <tr>
    <th>This tool </th>
    </tr>
    </thead>
    <tbody>
    <tr>
    <td>To view detail</td>
    </tr>
    <tr><td>
    <form method="get" method="post" name="entry">
    <strong>Cluster:</strong>


    <select name="Country">
    <option value="-1">Select</option>
    <option value="UK">UK</option>
    <option value="US">US</option>
    </select>

    <br>





    <input type="submit" value="Submit" onclick="useme();">




    </form>




    </body>

    </html>
    -------------

    java script--

    function useme() {
    url=document.entry.model.selection.value
    if (url=="UK")
    {
    /*here i want to call the page response.jsp */
    alert('complete')
    }
    else

    {
    /*here i want to call the page submit.jsp */
    alert('now')
    }
    }


    ---

    Please help

  2. #2
    Sno's Avatar
    Sno
    Sno is offline Senior Member
    Join Date
    Apr 2010
    Posts
    196
    Rep Power
    4

    Default

    1. Again, This is not Java!!! This is Javascript, find a javascript forum! haha
    2. GOOGLE
    3. GOOGLE
    4. GOOGLE
    5. Hint: This is simple, but your doing this script very illogically.
    :rolleyes: ~ Sno ~ :rolleyes:
    '-~ B.S. Computer Science ~-'

  3. #3
    newto is offline Member
    Join Date
    May 2010
    Posts
    17
    Rep Power
    0

    Default

    thank you for your helpful reply

  4. #4
    Sno's Avatar
    Sno
    Sno is offline Senior Member
    Join Date
    Apr 2010
    Posts
    196
    Rep Power
    4

    Default

    I'm not trying to be disrespectful, I am just saying that many people on here do not know javascript. There is a very large difference, You are doing web developing. Whereas Java is stand alone and setup as jar files.
    :rolleyes: ~ Sno ~ :rolleyes:
    '-~ B.S. Computer Science ~-'

  5. #5
    Sno's Avatar
    Sno
    Sno is offline Senior Member
    Join Date
    Apr 2010
    Posts
    196
    Rep Power
    4

    Default

    .... function(){ window.location = 'yourfile.jsp';}
    :rolleyes: ~ Sno ~ :rolleyes:
    '-~ B.S. Computer Science ~-'

  6. #6
    newto is offline Member
    Join Date
    May 2010
    Posts
    17
    Rep Power
    0

    Default

    I have already tried

    newjavascript,jsp

    function useme() {

    window.location= 'response.jsp';

    }

    jsp----------
    <html>
    <head>
    <title>Java Script use</title>
    <meta http-equiv="Content-Type" content="text/html;">
    <script type="text/javascript" src="newjavascript.js"></script>

    </head>
    <body bgcolor="#c5e7e0" >
    <form>
    <strong>Cluster:</strong>
    <select name="Country">
    <option value="-1">Select</option>
    <option value="UK">UK</option>
    <option value="US">US</option>
    </select>

    <br>
    <input type="SUBMIT" value="Submit" onclick="useme();" >
    </form>
    </body>
    </html>

    but it did not open to page response,jsp on the click of submit button

  7. #7
    newto is offline Member
    Join Date
    May 2010
    Posts
    17
    Rep Power
    0

    Default

    its been solved with function
    function test() {
    var url=document.redirect.selection.value
    document.location.href=url

    }

    thanks

Similar Threads

  1. redirect iframe if page cannot be displayed
    By moron3 in forum New To Java
    Replies: 1
    Last Post: 02-09-2010, 09:17 PM
  2. Redirect To Same Page
    By systech44 in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 12-08-2009, 11:27 AM
  3. redirect to html page
    By simo_mon in forum Java Servlet
    Replies: 3
    Last Post: 02-12-2009, 05:18 PM
  4. Redirect page in web service
    By bluesheeva in forum Advanced Java
    Replies: 3
    Last Post: 02-03-2009, 11:56 PM
  5. redirect page within a java applet
    By paul in forum Java Applets
    Replies: 1
    Last Post: 08-07-2007, 05:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •