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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Text to <td></td>!!! Pls Help

Status
Not open for further replies.

Forri

Programmer
Oct 29, 2003
479
MT
Hi

I have a table row <td id="category"></td>! I have a child window opened and the user has to select several categories. The choice is something like this:

Code:
 <input type="checkbox" id="cat1" cat="Category Name">

where cat is Category name value!

I would like that that value is put within the <td></td> tags in the parent form!

is it possible?

Thanks
Nick
 
Something like this should work:

Code:
// get a pointer to the TD
var destTD = window.opener.document.getElementById('category');

// if it doesn't have a textnode, create it
if (!destTD.childNodes || destTD.childNodes.length == 0) destTD.createTextNode('');

// populate it with the desired value
destTD.firstChild.nodeValue = 'yourValueHere';

Hope this helps,
Dan
 
This code goes in the child window where the checkbox is located.

Code:
<script Language="javascript">
function getValue(elmtRef) {
  if (elmtRef.checked) {
    opener.writeValue(elmtRef.cat);
  }
}
</script>

<form>

  <input type="checkbox" id="cat1" cat="Category Name" onClick="getValue(this);">

</form>

In the parent page where you want to write the information, put this javascript function in there.

Code:
<script Language="javascript">
function writeValue(strVal) {
  var elmtRef = getElementById('category');
  elmtRef.innerHTML = strVal;
}
</script>

That should work just fine.

ToddWW
 
be aware that arbitrary element attributes such as "cat" are not valid xhtml.



=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top