Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

new button

Status
Not open for further replies.

Mary10k

IS-IT--Management
Nov 8, 2001
103
US
I have a web page with a few rows displayed in a table. I would like to display some text that flashes or stands out in a different color when a new row is added to the table.

How can I disable the text ("New!") after a certain amount of time or after a user clicks on the new row and previews it?

Thank you.
 
If you are already adding the new row dynamically, why not remove the old "New" sign at that time?

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
zen.gif

 
Sorry, are you adding the new rows on the client-cide via javascript or on the server-side by PHP/ASP/ColdFusion?

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
zen.gif

 
In this case, I am adding the new rows manually with HTML. I was thinking I could use java script to remove the "new" button when appropriate.
 
Code:
<table id="myTable" border=1 width=300>
  <tr><td>New</td><td>infoM.</td><td>More info</td></tr>
</table>

<input type=button onClick="addRow()" value="add">

<script>
	function addRow(){
		theTable = document.getElementById("myTable")
		
		theTable.rows(theTable.rows.length-1).cells(0).innerHTML = "&nbsp;"
		
		theRow = theTable.rows(0).cloneNode(true)
		theTable.firstChild.appendChild(theRow)
		theRow.cells(0).innerHTML = "New"
	}
</script>

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
zen.gif

 
Thank you. This is a great help, but I have a few modifications I would like your help with. I was thinking something might not be new to a user if they have already read the new addition. Is there a way I can determine if a user id has already read the data, which would make it old?
 
If you are not using server-side scripting (ie - a database driven page) then you will need to use cookies to do what you ask...

from
Code:
<HTML>
<HEAD>
	<TITLE>New for You</TITLE>
	<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
		<!-- Hide script from older browsers
	
	    now = new Date
	    expireDate = new Date
	    expireDate.setMonth(expireDate.getMonth()+6)
		lastVisit = new Date(cookieVal("pageVisit"))
		document.cookie = "pageVisit="+now+";expires=" + expireDate.toGMTString()
		
		function cookieVal(cookieName) {
			thisCookie = document.cookie.split("; ")
	  	    for (i=0; i<thisCookie.length; i++) {
	  	        if (cookieName == thisCookie[i].split("=")[0]) {
	  	        	return thisCookie[i].split("=")[1]
	  	        }
	   	    }
			return "1 January 1970"
		}
		
		function newCheck(yyyy,mm,dd) {
			lastChgd = new Date(yyyy,mm-1,dd)
			
			if (lastChgd.getTime() > lastVisit.getTime()) {
				document.write("<IMG SRC='new.gif' WIDTH=28 HEIGHT=11 ALT='new'>")
			}
		}
		
		// End hiding script -->
	</SCRIPT>	
</HEAD>
<BODY BGCOLOR=WHITE>
<H2>
	Negrino and Smith's new book is out: <A HREF="[URL unfurl="true"]http://www.chalcedony.com/javascript/">JavaScript[/URL] for the World Wide Web: Visual QuickStart Guide, 3rd Edition</A>
	<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
		<!-- Hide script from older browsers
		
		newCheck(1999,5,4)
		
		// End hiding script -->
	</SCRIPT>
	<P>
	<A HREF="[URL unfurl="true"]http://www.chalcedony.com/java/">Java[/URL] for the World Wide Web: Visual QuickStart Guide</A>
	<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
		<!-- Hide script from older browsers
		
		newCheck(1998,9,3)
		
		// End hiding script -->
	</SCRIPT>
	<P>
</H2>
</BODY>
</HTML>

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
zen.gif

 
Hi,

I used the above referenced code from and it works great with one exception. I can't get the New button to display. It looks as if a place holder is displaying, but no button. I created a button, named it the same as what is in the code.

Any suggestions?
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top