You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by Bert Heikamp <be...@tooclose.nl> on 2008/12/08 13:13:01 UTC
set a value in a FormTable onChange of another Cell
Hi All,
I have a fromTable with different fields, now I want to set a checkBow in
the first Row to Changed when modifying another value in that row, I don't
want to save the table, so It should be done with javascript, or with Ajax.
Is there a way to do this ?
kind Regards, Bert
Re: set a value in a FormTable onChange of another Cell
Posted by Bob Schellink <sa...@gmail.com>.
Hi Bert,
Bert Heikamp wrote:
> Hi All,
>
> I have a fromTable with different fields, now I want to set a checkBow
> in the first Row to Changed when modifying another value in that row, I
> don't want to save the table, so It should be done with javascript, or
> with Ajax. Is there a way to do this ?
Do you want to "check" the checkbox when an input field in the row
change? Sounds like a use case for Javascript more than Ajax (unless
you need to retrieve data from the server when a value change).
If you use a Javascript library such as JQuery the following snippet
could work:
<script type="text/javascript">
$(document).ready(function() {
// Grab each row in table named 'table'
$('#table tr').each(function() {
// Store reference to the current row
var tr = this;
// Select all HTML input elements inside the given row
// and register an onchange listener
$(':input', tr).change(function(event) {
// Ensure the event type is not a checkbox, otherwise
// one cannot deselect the checkbox
if (event.target.type !== 'checkbox') {
// Select the checkbox from the row and check it
$(':checkbox', tr).attr("checked", "checked");
}
})
});
});
</script>
If you use straight Javascript you'll probably have to do more work
though.
Hope this helps.
kind regards
bob