CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> General/Other

 editable grids and calling name of textbox in javascript

Print topic Send  topic

Author Message
CodeChargenewbie

Posts: 114
Posted: 12/20/2007, 1:45 PM

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?
View profile  Send private message
DonB
Posted: 12/20/2007, 6:02 PM

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/
>

CodeChargenewbie

Posts: 114
Posted: 12/21/2007, 10:23 AM

Quote DonB:
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/
>



Thank you. Is the above code self-contained, or are you using that jquery library? Any chance you can point me in the right direction as to how to write an onchange event manually using codecharge? Using the built-in onchange event is not helping (can execute), and, as I said before, the onchange event in the properties window doesn't even execute. If you can point me how to write a "hello world" version of a manual onchange event in codecharge, that'd be great. In other words, creating my own custom event. Thank you.
View profile  Send private message
CodeChargenewbie
Posted: 12/21/2007, 10:23 AM

Quote DonB:
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/
>



Thank you. Is the above code self-contained, or are you using that jquery
library? Any chance you can point me in the right direction as to how to write
an onchange event manually using codecharge? Using the built-in onchange event
is not helping (can execute), and, as I said before, the onchange event in the
properties window doesn't even execute. If you can point me how to write a
"hello world" version of a manual onchange event in codecharge, that'd be great.
In other words, creating my own custom event. Thank you.
---------------------------------------
Sent from YesSoftware forum
http://forums.codecharge.com/
CodeChargenewbie

Posts: 114
Posted: 12/21/2007, 10:31 AM

Oh, I see, that's the jquery thing. Well, I hope that it provides the answer for me. The problem is I want it to only effect what the user chooses, not everything.
View profile  Send private message
CodeChargenewbie

Posts: 114
Posted: 12/21/2007, 1:09 PM

I figured out what the problem was, but I do like that jquery library. Basically, I had some custom code for a client-side onchange event in the events tab, under Properties. NOW, what I was trying to execute was an onchange event in the format tab. I think was happening is the Events tab took precedent over the Format tab and subsequently ignored the onchange event inserted into the html by me. I sure as heck wish Codecharge would make that clear in its user guide!
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.