Look at jquery.com
You can easily write an onclick event and bind a handler/function to many
controls in a single line of code. Each control will be referenceable as a
distinct DOM element so it works perfectly no matter how many of them you
have.
e.g.
<script language="javascript">
$(".plus").click( function (e) {
if ($(e.target).attr("class")=="plus opened") {
$(e.target).parent().find("tbody.details").hide();
$(e.target).removeClass("opened");
$(e.target).addClass("closed");
}
else {
$(e.target).parent().find("tbody.details").show();
$(e.target).removeClass("closed");
$(e.target).addClass("opened");
}
});
</script>
This example makes <tbody class='details'> elements expand (open) or shrink
(close) when a +/- button (class='plus') is clicked, by altering the CSS
class attribute of the tbody. I can put any number of these on one page and
never have to fiddle with individual <tbody>'s, for example in a grid with
many rows.
Imagine this employed in a Grid, where each Grid row is many <tr>...</tr>
'rows', and each one is enclosed in a <tbody>...</tbody>. That one little
bit of jquery code makes each <tbody> of the grid open/close when the button
beside it is clicked.
My point is, you need not worry about each of your textboxes having a
different name nor would you need to code six different 'onclick' events.
--
DonB
http://ccswiki.gotodon.net
"CodeChargenewbie" <
CodeChargenewbie@forum.codecharge> wrote in message
news:2476ae26a3fdde@news.codecharge.com...
> I am using an editable grid, and I noticed that codecharge automatically
> increments a textbox's name in html. Let's say I have a textbox called
Example.
> The editable grid generates, say, 6 textboxes, with each textbox
enumerating
> with name=Example_1 through name=Example_6 in the HTML view.
>
> There are two problems here:
>
> First problem: the onchange event does not execute. I created a
javascript
> function called foobar(). I navigated to Properties->Format->Events and
typed
> in "foobar();" for onchange. I wonder if it has something to do with how
> codecharge automatically generates the grid...
>
> Second problem: Let's say I want to write the value of Example_2 to the
screen.
> In javascript, I could say
> document.write(document.forms["formname"].Example_2.value); and I'd be
done.
> The problem is this needs to be dynamic. The amount of Example textboxes
may
> vary and it should not be hardcoded. I tried creating a function that
takes the
> html name (here, it is Example_2) as an argument and then saying
> document.write(document.forms["formname"].Argument.value); but that
doesn't
> work.
>
> What should I do? Give up?
> ---------------------------------------
> Sent from YesSoftware forum
>
http://forums.codecharge.com/
>