开发者

calling a function

开发者 https://www.devze.com 2022-12-11 07:34 出处:网络
I made a database, I am pr开发者_开发技巧inting my required field in a marquee. Now i want that

I made a database, I am pr开发者_开发技巧inting my required field in a marquee.

Now i want that

if (change>0);
print (image_21);
else print (image_2);

This is the code I am using:

<%@page  import="java.sql.*" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <script type="text/javascript">


          function img()
            {
                if(change > 0)
                upimg();

                 else
                downimg();

            }
                    function upimg()
    {
             <img src="up.png" >
    }
           function downimg()
    {
             <img src="down.png">
    }  
        </script>
    </head>
    <body onload=" img() " >


    <marquee style="font-size: 28pt; text-transform: uppercase; font-family: Times New Roman; color: #000fff; font-weight: bold">

    <% 
try{
try{}
catch(Exception e)
{}


    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     Connection conn=DriverManager.getConnection("jdbc:odbc:all","","");

         Statement stat=null;
     ResultSet rst=null;
     stat=conn.createStatement();


             String query="select * from list ";
             rst=stat.executeQuery(query);

             while(rst.next())
             {


String Company=(String)rst.getString("Company");
String Open_Price=(String)rst.getString("Open_Price");
String change=(String)rst.getString("change");


    out.println(Company);
    out.println("  ");
    out.println(Open_Price);
    out.println(",");        
}
}
catch(Exception e)
        {
    }

%>


    </marquee>



    </body>
</html>

Can anybody please help?


I'm afraid you're mixing up JSP and Javascript issues.

I notice that in the server side (i.e. JSP code) you're eating up any Exception thrown:

catch(Exception e) { }

which is bad, making it impossible to detect any underlying problem.

Aside from that, and assuming that change is valid Javascript (i.e. client-side) variable (I can't see it referenced anywhere else), I think there is a problem in the Javascript function:

function upimg()
{
     <img src="up.png" >
}

I'd rather put a static <img> in the HTML body, and dynamically change its source:

<body onLoad="img ()">
    ...
    <img name="dynImg" />
</body>

and then

function upimg()
{
    document["dynImg"].src = "up.png";
}

(Check the syntax).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号