Help With Getting Element In Javascript

Joined: 11/28/2008

We are using the Prototype javascript library. So if I want to select an element in the DOM by id I can just use $("theElementID")

Is there a way to select a child element of a parent, where you know the parent id and the child node type? Eg, if I had:

<tr id="someID">
<td><input type="text" /></td>
</tr>

Is there a way to get the input element in the tr with ID "someID"? I could just give it an ID of it's own, but I'm more keen to try and only give an ID to the table row.

Cheers

~Andrew~

Joined: 11/28/2008
I don't know about prototype,

I don't know about prototype, but with jquery it would look something like this:

CODE
//HTML
<tr id="someID">
<td><input type="text" name="my_name" /></td>
</tr>

//Javascript
// grab single row by element name
$("#someID input[@name='my_name']")

// grab all input element with the table row
$("#someID input")

perhaps it's similar?

Joined: 11/28/2008
Thanks, Paul. It might be

Thanks, Paul. It might be similar in Prototype (I'd rather use jQuery, but it wasn't my choice). I've realised now that even if this was possible, it wouldn't work for me as I now need to be able to select different table cells under a certain row, and I can't see how to do that without giving them all IDs.

Cheers anyway.

~Andrew~