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

Need suggestion on JAVASCRIPT powered forms

Status
Not open for further replies.

darkling235

Programmer
Oct 30, 2006
24
US
I'm looking for an implementation suggestion. I don't usually do much with graphics so I'm not totally sure how to do this.

My client wants a user to be able to click on an "item" in a "table" and have that trigger an event. Basically what he wants is if you look at the main page on the forum here, if you clicked on any of the "bands" of alternating colors, the entire "band" will throw an event so I can highlight it and do something with it. Can anyone suggest an implementation for this idea? I'm not sure what to look up.
Thank You
 
You mean something like this?
Code:
<table>
  <tr onclick="this.style.backgroundColor='blue';">
    <td>&nbsp;Blue&nbsp;</td>
  </tr>
  <tr onclick="this.style.backgroundColor='red';">
    <td>&nbsp;Red&nbsp;</td>
  </tr>
</table>

Lee
 
Yes thank you, that solves half my problem right there, but can you think of any way to know which <TR> has been selected, or just what text has?
 
What needs to be done after the selection? You stated you wanted to "do something with it", but didn't give any details about what you want to do. Put a function call in with the color change code, then write the function to do whatever you want done.

Lee
 
Well long story short I need to take the data in the TR and send it to a servlet via an xmlhttp request so I can process it. Maybe if I try writing a send method and pass in the data to be sent? I could have different arguments for each TR? I'm not sure if that'll work. I'll try it.
 
[tt]<table>
<tr onclick="this.style.backgroundColor='blue';[blue]alert(((event.srcElement)?event.srcElement:event.target).parentNode.rowIndex)[/blue]">
<td>&nbsp;Blue&nbsp;</td>
</tr>
<tr onclick="this.style.backgroundColor='red';[blue]alert(((event.srcElement)?event.srcElement:event.target).parentNode.rowIndex)[/blue]">
<td>&nbsp;Red&nbsp;</td>
</tr>
</table>
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top