Jasbir21
asked on
Kuldeepchaturvedi:Suggestion using javascript for pop-up_HELP
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:33 06/mydatab ase?user=; password=" ;
Connection connection = null;
ResultSet rs = null;
try
{
Class.forName("com.mysql.j dbc.Driver ").newInst ance();
connection = DriverManager.getConnectio n(connecti onURL, "", "");
}//try
catch( SQLException ex )
{
ex.printStackTrace() ;
}
catch( ClassNotFoundException ex )
{
ex.printStackTrace() ;
}
%>
<%
String my="select id,desc from color";
Statement stmt=connection.createStat ement();
ResultSet rs2=stmt.executeQuery(my);
%>
Existing Skills :
<select name="ChooseSkill"
>
<%
while(rs2.next()){ %>
<option value=<%=rs2.getString(1). trim()%>>< %=rs2.getS tring(1).t rim()%></o ption>
<%}%>
</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
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:33
Connection connection = null;
ResultSet rs = null;
try
{
Class.forName("com.mysql.j
connection = DriverManager.getConnectio
}//try
catch( SQLException ex )
{
ex.printStackTrace() ;
}
catch( ClassNotFoundException ex )
{
ex.printStackTrace() ;
}
%>
<%
String my="select id,desc from color";
Statement stmt=connection.createStat
ResultSet rs2=stmt.executeQuery(my);
%>
Existing Skills :
<select name="ChooseSkill"
>
<%
while(rs2.next()){ %>
<option value=<%=rs2.getString(1).
<%}%>
</select>
<a href="javascript:dothis();
</p>
<input type="submit" value="Submit">
</form>
</body>
</html>
How do i assign the desc value to the javascript variable
Thanks
oops...
<script>
var x =<%=rs2.getString(1).trim( )%>
</script>
<script>
var x =<%=rs2.getString(1).trim(
</script>
ASKER
Hi,
How do i display it in javascript that in javascript?
How do i display it in javascript that in javascript?
ASKER
I mean, how do i tell or make a javascript function that says if this userid display the description
Thanks
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hi,
The error i got is
:org.apache.jasper.JasperE xception: 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\Cata lina\local host\jsp-e xamples\or g\apache\j sp\jsp2\co l_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\Cata lina\local host\jsp-e xamples\or g\apache\j sp\jsp2\co l_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\Cata lina\local host\jsp-e xamples\or g\apache\j sp\jsp2\co l_jsp.java :88: ')' expected
out.write("\"\r\n");
^
3 errors
org.apache.jasper.compiler .DefaultEr rorHandler .javacErro r(DefaultE rrorHandle r.java:128 )
org.apache.jasper.compiler .ErrorDisp atcher.jav acError(Er rorDispatc her.java:3 51)
org.apache.jasper.compiler .Compiler. generateCl ass(Compil er.java:41 3)
org.apache.jasper.compiler .Compiler. compile(Co mpiler.jav a:453)
org.apache.jasper.compiler .Compiler. compile(Co mpiler.jav a:437)
org.apache.jasper.JspCompi lationCont ext.compil e(JspCompi lationCont ext.java:5 55)
org.apache.jasper.servlet. JspServlet Wrapper.se rvice(JspS ervletWrap per.java:2 91)
org.apache.jasper.servlet. JspServlet .serviceJs pFile(JspS ervlet.jav a:301)
org.apache.jasper.servlet. JspServlet .service(J spServlet. java:248)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 856)
note The full stack trace of the root cause is available in the Tomcat logs.
Thanks
The error i got is
:org.apache.jasper.JasperE
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\Cata
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\Cata
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\Cata
out.write("\"\r\n");
^
3 errors
org.apache.jasper.compiler
org.apache.jasper.compiler
org.apache.jasper.compiler
org.apache.jasper.compiler
org.apache.jasper.compiler
org.apache.jasper.JspCompi
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
note The full stack trace of the root cause is available in the Tomcat logs.
Thanks
ASKER
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?
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?
ASKER
Hi,
I changed this :
(document.color.value.Choo seSkill) to
document.value.color.Choos eSkill
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
I changed this :
(document.color.value.Choo
document.value.color.Choos
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
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.backgroun dColor = "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
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.backgroun
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
ASKER
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?
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....
If it is ie 5.5 then it should be working....
ASKER
ok, thanks
ASKER
I have upgraded the browser and its working fine...
..Thanks again
..Thanks again
glad to be of help....:-)
</script>