?
Solved

Kuldeepchaturvedi:Suggestion using javascript for pop-up_HELP

Posted on 2003-10-29
14
Medium Priority
?
259 Views
Last Modified: 2010-04-01
Hi,
  I liked the idea of using javascript for the colorid question. How do you do that? I found out that using skill.jsp takes a long time
<html>
<body>
<form action=color.jsp>

<%
String connectionURL = "jdbc:mysql://localhost:3306/mydatabase?user=;password=";
Connection connection = null;

ResultSet rs = null;
try
{

 
   Class.forName("com.mysql.jdbc.Driver").newInstance();
  connection = DriverManager.getConnection(connectionURL, "", "");
 
 


}//try
catch( SQLException ex )
{
  ex.printStackTrace() ;
}
catch( ClassNotFoundException ex )
{
  ex.printStackTrace() ;
}

%>


<%
String my="select id,desc from color";
Statement stmt=connection.createStatement();
ResultSet rs2=stmt.executeQuery(my);
%>


Existing Skills :  

<select name="ChooseSkill"
>

<%
while(rs2.next()){ %>

<option value=<%=rs2.getString(1).trim()%>><%=rs2.getString(1).trim()%></option>
<%}%>
</select>


<a href="javascript:dothis();">Desc</a>


</p>

<input type="submit" value="Submit">
</form>
</body>
</html>



How do i assign the desc value to the javascript variable



Thanks

0
Comment
Question by:Jasbir21
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 3
  • 3
14 Comments
 
LVL 5

Expert Comment

by:apparition
ID: 9642809
<script>

</script>
0
 
LVL 5

Expert Comment

by:apparition
ID: 9642821
oops...
<script>
     var x =<%=rs2.getString(1).trim()%>
</script>
0
 

Author Comment

by:Jasbir21
ID: 9643106
Hi,
  How do i display it in javascript that in javascript?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Jasbir21
ID: 9643143
I mean, how do i tell or make a javascript function that says if this userid display the description

Thanks
0
 
LVL 5

Accepted Solution

by:
apparition earned 800 total points
ID: 9643354
Question Title: Kuldeepchaturvedi:Suggestion using javascript for pop-up_HELP
Author: Jasbir21
Points: 200
Date: 10/29/2003 05:22AM PST
 


Hi,
  I liked the idea of using javascript for the colorid question. How do you do that? I found out that using skill.jsp takes a long time
<html>
<script>
  var colorDesc = new Array ()
      
   function  displayDesc(index) {
          alert (colorDesc[index])
   }
</script>
<body>
<form action=color.jsp name="color">

<%
String connectionURL = "jdbc:mysql://localhost:3306/mydatabase?user=;password=";
Connection connection = null;

ResultSet rs = null;
try
{

 
   Class.forName("com.mysql.jdbc.Driver").newInstance();
  connection = DriverManager.getConnection(connectionURL, "", "");
 
 


}//try
catch( SQLException ex )
{
  ex.printStackTrace() ;
}
catch( ClassNotFoundException ex )
{
  ex.printStackTrace() ;
}

%>


<%
String my="select id,desc from color";
Statement stmt=connection.createStatement();
ResultSet rs2=stmt.executeQuery(my);
%>


Existing Skills :  

<select name="ChooseSkill"
>

<%
int x = 0
while(rs2.next()){
%>
<script>
  colorDesc[<%=x>] = "<%=rs2.getString(2).trim()%>"
</script>
<option value=<%=x%>><%=rs2.getString(1).trim()%></option>
<%
x ++;
}%>
</select>


<a href="#" onclick="displayDesc(document.color.value.ChooseSkill);return false;">Desc</a>


</p>

<input type="submit" value="Submit">
</form>
</body>
</html>
 
 
0
 

Author Comment

by:Jasbir21
ID: 9647010
hi,

 The error i got is

:org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 59 in the jsp file: /jsp2/col.jsp

Generated servlet error:
    [javac] Compiling 1 source file

C:\apache\tomcat\work\Catalina\localhost\jsp-examples\org\apache\jsp\jsp2\col_jsp.java:87: illegal start of expression
      out.print(x>] = "<%=rs2.getString(2).trim());
                  ^



An error occurred at line: 59 in the jsp file: /jsp2/col.jsp

Generated servlet error:
C:\apache\tomcat\work\Catalina\localhost\jsp-examples\org\apache\jsp\jsp2\col_jsp.java:87: unclosed string literal
      out.print(x>] = "<%=rs2.getString(2).trim());
                      ^



An error occurred at line: 59 in the jsp file: /jsp2/col.jsp

Generated servlet error:
C:\apache\tomcat\work\Catalina\localhost\jsp-examples\org\apache\jsp\jsp2\col_jsp.java:88: ')' expected
      out.write("\"\r\n");
                         ^
3 errors


      org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:128)
      org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
      org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:413)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:453)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:437)
      org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:555)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


note The full stack trace of the root cause is available in the Tomcat logs.


Thanks
0
 

Author Comment

by:Jasbir21
ID: 9647484
Hi,
  I found the error, needed to %>

But now when i run it, i get document.color.value is not an object.

Could you pls help?
0
 

Author Comment

by:Jasbir21
ID: 9647520
Hi,
  I changed this :
(document.color.value.ChooseSkill) to

document.value.color.ChooseSkill

and it worked thanks.

When the window pops up, it goes in the middle,
is there anywhere to make it near the desc button.

Thanks



0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 9648074
So I see you got the answer before I ever got a chance to have a look at it...:-)
as far as your last wish of making it appear near desc button goes... than you will  have to use a popup window instead of alert...
something like this...
>>>>>
 function  displayDesc(index) {
         alert (colorDesc[index])
  }

will change to
>>>>>>
function displayDesc(index)
{
var oPopup = window.createPopup();
var oPopupBody = oPopup.document.body;
      oPopupBody.style.backgroundColor = "lightyellow";
      oPopupBody.style.border = "solid black 1px";    
    oPopupBody.innerHTML = colorDesc[index];
    oPopup.show(100, 100, 200, 50, document.body);}
}

now these co-ordinates (100,100,200,50) can be changed to your own liking...

Hope this helps.
Regards
0
 

Author Comment

by:Jasbir21
ID: 9648237

Hi,
   I was really looking for thant , thanks, when i tried to run it, i had a runtime error that says:
Object doesn't support this property or method and when try to debug it i had the debugger stop at:
var oPopup = window.createPopup();

What do i do?
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 9648381
createpopup is supported only IE 5.5 and above, so make sure your browser is IE5.5 or above otherwise I am afraid it will not be working...
If it is ie 5.5 then it should be working....
0
 

Author Comment

by:Jasbir21
ID: 9649229
ok, thanks
0
 

Author Comment

by:Jasbir21
ID: 9649498
I have upgraded the browser and its working fine...
..Thanks again
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 9649626
glad to be of help....:-)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
What's worse than having your data encrypted by ransomware? Getting attacked by a so-called "wiper," which simply destroys the data and offers you no hope of ever seeing it again.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question