I need to make dynamic pages with onclick change color

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prabhuaradhan
    New Member
    • May 2010
    • 2

    #1

    I need to make dynamic pages with onclick change color

    Code:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <meta http-equiv="refresh" content="refreshrate">
    
    <title>Insert title here</title>
    <link rel="stylesheet" href="C://Users/203243/wal/Number/WebContent/style/stylee.css" type="text/css"></link>
    <script type="text/JavaScript">
    
    </script>
    </head>
    <body bgcolor="ffff80" >
    <font color="ff0000">
    <% 
    int[] a={1,2,3,4,5,6,7,8,9,10};
      for(int i : a){
    	 %> 
    	 <a href="#" <%out.println(i);%>  >
    	  
      <% out.println(i);
    	 if( i<10)
    	 {
    	 out.println("|");	
    	 }
      }
      %>
      </a>
      </font>
    </body>
    </html>

    this is program I need to improvise with onclick on page number it should change color and after I click second page it should refresh previous one and need to change color .pls anyone help
    Last edited by acoder; May 5 '10, 02:13 PM. Reason: Please use [code] tags when posting code
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Where's your JavaScript code?

    PS. use CSS for colours/styling.

    PPS. please use [code] tags

    Comment

    • prabhuaradhan
      New Member
      • May 2010
      • 2

      #3
      Originally posted by acoder
      Where's your JavaScript code?

      PS. use CSS for colours/styling.

      PPS. please use [code] tags
      Thats Why some one edit and make it good ..
      I m totally new to java and script . try to edit above code ...
      thankx in advance

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        There's no JavaScript code to edit!

        Anyway, add an onclick to each link to call a function with the page number passed to the function, e.g. changeCol(1).

        In your function, change the colour of the page:
        Code:
        elem.style.backgroundColor=col;
        where elem is the element to change (possible document.body) and col is the colour. Alternatively, use classes by defining them in your CSS code and changing the class instead of setting the background colour directly.

        Comment

        Working...