Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: DHTML
Expertise: Beginner
Jan 29, 1999

Dynamically Changing Table Values

Question:
I have a table that contains the values returned from a SQL database. I have created a division within each cell. The ID value for the division is the keyvalue of the recordset. On mouseover, the DIV that I store the name of the current DIV in is a hidden form input. I also move and make visible a select input item and set its value to the value currently in the table cell. The idea is that the user picks a new value and I update the table with the new value. I set the new value using this function:
function selectSupported(oObject){
	var strSelText =
oObject.options[oObject.selectedIndex].text //oObject is the
select input
	var strCurValue =
document.all.item(document.all.hidCurSupported.value).innerText
//getting the value currently in the table
	if (strSelText != strCurValue)
document.all.item(document.all.hidCurSupported.value).innerText
 = strSelText; //set the new value
}
This code works, however, it only works once. After I set the inner text of the DIV in the table cell, the table cell no longer responds to mouse over events. Any ideas?

Answer:
While I can't see anything obvious, here's a couple of possibilities that you may want to explore. You may need to check that you're not inadvertently creating two DIVs with the same ID. If that happens, then referencing gets screwed up because you inadvertently create a collection with that ID. For example:

This is line 1
This is line 2
You'll generate an error if you then attempt to say in a script,
var data=document.all("mydoc").innerText
At this point, you actually need to refer to the entities as if they were a collection:
var data=document.all("mydoc")[1].innerText
alert data
This will pop-up an alert box saying "This is line 2".

You should also make sure you're not wiping out the object that contains the mouseover handler when you do the innerText call. I presume that you invoke the onchange event handler in the

Submit a Tip Browse "Web Development" Tips Browse All Tips
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap