CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> Archive -> CodeChargeStudio.Discussion

 Reference field on editable grid with javascript

Print topic Send  topic

Author Message
Bon733
Posted: 10/27/2003, 3:16 PM

CodeChargeStudio(2.x)

I am trying to create on OnChange script that will populate another field on
a grid (on the same row) if certain conditions exist. However I am having a
hard time referencing the field on the grip using javascript. Any ideas?

DonB
Posted: 10/27/2003, 4:36 PM

I assume you are already familiar with the basic document object of the
browser, if not you need to read up on the document and form objects.

Basically, the form object contains references to your controls (fields) -
they have to be in a form, not just anywhere in the HTML. From memory, I
think "document.form(index).controlname" is the way to reference them.

If you are using a plain Grid (not EditableGrid), then you have a couple of
problems that will prevent you from doing what you ask. (1) the Grid has no
<FORM> and (2) the grid has no controls that you can manipulate. Look at
the HTML - if you see <INPUT>elements then you will be able to access them
by name and the name will be shown like "name='somthing' within the <>
brackets. If all you see is a stream of HTML text with no tags for INPUT,
SELECT, etc., then there is nothing you CAN access via javascript, that is
without parsing and rewriting the entire document stream.

You would have no trouble copying data from control to control in either a
Record or an EditableGrid - although the E.G. is going to have many controls
with similar names but ending in "_1", "_2", and so on to indicate the row
they occupy, so you will need to do some work to figure out which ones to
use.

--
DonB

http://www.gotodon.com/ccbth


"Bon733" <bon@nospam.com> wrote in message
news:bnk90e$lbd$1@news.codecharge.com...
> CodeChargeStudio(2.x)
>
> I am trying to create on OnChange script that will populate another field
on
> a grid (on the same row) if certain conditions exist. However I am having
a
> hard time referencing the field on the grip using javascript. Any ideas?
>
>

Steve Kitchen
Posted: 10/28/2003, 12:33 AM

Set your onchange event something like ..

onchange="Product_onchange('{RowIDAttribute}'); return false;

where RowIDattribute is embedded in the <TR> of the grid (check out the
example pack EditableGridAddButton for how to set this up).

Then in your Javascript 'Product_onchange' function


function Product_onchange(RowID) {

var val = eval("document.invoice.product_code_"+RowID+".value");
//retrieves current value from grid field

// do your changes here

eval("document.invoice.description_"+RowID+".value = '"+rowdescrip+"'"); //
will put rowdescrip into the description field on the grid


I use this to update several fields, and have also combined it with a
pop-up, and a server lookup function which doesn't refresh the page (jsrs),
so it is possible, even if the code isn't very pretty :-)


Regards,

Steve Kitchen
s.kitchen@burningfrog.be


Karen Tan
Posted: 10/29/2003, 11:50 PM

I added the javascript using 'Add action' in the Onchange client event
and then I copied their references to the control and mine looks
something like this:

//Validate Minimum Value @45-EACE9D75
if(sessionlinesElements[element_i][sessionlinesorder_qtyID].value <
1) {
alert("Please enter a quantity from 1 to 999,999,999")
sessionlinesElements[element_i][sessionlinesorder_qtyID].focus();
return false;
}
//End Validate Minimum Value


The form name is sessionlines and the control name is order_qty, while
element_i is the counter for the array that I got passed from the
generated code.

Hope that helps.

Bon733 wrote:
> CodeChargeStudio(2.x)
>
> I am trying to create on OnChange script that will populate another field on
> a grid (on the same row) if certain conditions exist. However I am having a
> hard time referencing the field on the grip using javascript. Any ideas?
>
>
Karen Tan
Posted: 10/29/2003, 11:53 PM

Hi Steve,

I was trying to do a server lookup like what you've done but decided it
was beyond me. I need to populate the textbox with the product
description after the product has been selected from the listbox.

If you don't mind, can you give me some pointers on what to code in the
function triggered during the onchange event. I just don't know how to
use javascript to get some value from the database.

TIA!

-Karen

Steve Kitchen wrote:

> Set your onchange event something like ..
>
> onchange="Product_onchange('{RowIDAttribute}'); return false;
>
> where RowIDattribute is embedded in the <TR> of the grid (check out the
> example pack EditableGridAddButton for how to set this up).
>
> Then in your Javascript 'Product_onchange' function
>
>
> function Product_onchange(RowID) {
>
> var val = eval("document.invoice.product_code_"+RowID+".value");
> //retrieves current value from grid field
>
> // do your changes here
>
> eval("document.invoice.description_"+RowID+".value = '"+rowdescrip+"'"); //
> will put rowdescrip into the description field on the grid
>
>
> I use this to update several fields, and have also combined it with a
> pop-up, and a server lookup function which doesn't refresh the page (jsrs),
> so it is possible, even if the code isn't very pretty :-)
>
>
> Regards,
>
> Steve Kitchen
>s.kitchen@burningfrog.be
>
>
>
Steve Kitchen
Posted: 10/30/2003, 1:16 AM

Hi Karen,

I use jsrsClient & jsrsServer to perform the background lookups from the
database.

You can pick the code up from sourceforge.net (just do a search for jsrs
....).
The server & client modules should integrate without the need for any
changes if you're coding in PHP. (Smiply include the js module at the top of
the html of any page that needs the function). If you put both modules in
your CCS source folder, they should get published with your project.

In my previous posting, replace the "// do your changes here" bit with the
jsrs function to lookup the data you need from the database.

There is a reasonable example of how to use the code supplied with jsrs, so
you shouldn't have too many problems getting it to do what you want.

The JavaScript necessary to poke the values back into the editablegrid is
probably the ugliest part :-)

If you're still lost, let me know & I'll see what I can do to help ...

Regards,

Steve Kitchen
s.kitchen@burningfrog.be


"Karen Tan" <architech@awes2001.com> wrote in message
news:bnqg1j$ln2$1@news.codecharge.com...
> Hi Steve,
>
> I was trying to do a server lookup like what you've done but decided it
> was beyond me. I need to populate the textbox with the product
> description after the product has been selected from the listbox.
>
> If you don't mind, can you give me some pointers on what to code in the
> function triggered during the onchange event. I just don't know how to
> use javascript to get some value from the database.
>
> TIA!
>
> -Karen
>
> Steve Kitchen wrote:
>
> > Set your onchange event something like ..
> >
> > onchange="Product_onchange('{RowIDAttribute}'); return false;
> >
> > where RowIDattribute is embedded in the <TR> of the grid (check out the
> > example pack EditableGridAddButton for how to set this up).
> >
> > Then in your Javascript 'Product_onchange' function
> >
> >
> > function Product_onchange(RowID) {
> >
> > var val = eval("document.invoice.product_code_"+RowID+".value");
> > //retrieves current value from grid field
> >
> > // do your changes here
> >
> > eval("document.invoice.description_"+RowID+".value =
'"+rowdescrip+"'"); //
> > will put rowdescrip into the description field on the grid
> >
> >
> > I use this to update several fields, and have also combined it with a
> > pop-up, and a server lookup function which doesn't refresh the page
(jsrs),
> > so it is possible, even if the code isn't very pretty :-)
> >
> >
> > Regards,
> >
> > Steve Kitchen
> >s.kitchen@burningfrog.be
> >
> >
> >
>

Karen Tan
Posted: 11/01/2003, 11:34 PM

Hi Steve,

I've been reluctant to post this as I'm quite embarassed to say that
after looking at the only sample I found on the site so many times, I
still can't figure out what to do with the code. The sample that I've
found is made up of 3 listboxes and I can't figure out how the form's
controls (lstMake, lstModel, lstOptions) relate to the
variables/functions in the code (makeList, modelList, optionsList).

Furthermore, it all looks like php codes to me so should I be coding
this in the code part of the CCS page or in the html? If you don't
mind, do you have a sample to share? I've tried looking into the forum
and other places but can't seem to find anything that I can understand.
Sorry to be so ignorant. Really appreciate your help. TIA!

-Karen

Steve Kitchen wrote:
> Hi Karen,
>
> I use jsrsClient & jsrsServer to perform the background lookups from the
> database.
>
> You can pick the code up from sourceforge.net (just do a search for jsrs
> ...).
> The server & client modules should integrate without the need for any
> changes if you're coding in PHP. (Smiply include the js module at the top of
> the html of any page that needs the function). If you put both modules in
> your CCS source folder, they should get published with your project.
>
> In my previous posting, replace the "// do your changes here" bit with the
> jsrs function to lookup the data you need from the database.
>
> There is a reasonable example of how to use the code supplied with jsrs, so
> you shouldn't have too many problems getting it to do what you want.
>
> The JavaScript necessary to poke the values back into the editablegrid is
> probably the ugliest part :-)
>
> If you're still lost, let me know & I'll see what I can do to help ...
>
> Regards,
>
> Steve Kitchen
>s.kitchen@burningfrog.be
>
>
> "Karen Tan" <architech@awes2001.com> wrote in message
>news:bnqg1j$ln2$1@news.codecharge.com...
>
>>Hi Steve,
>>
>>I was trying to do a server lookup like what you've done but decided it
>>was beyond me. I need to populate the textbox with the product
>>description after the product has been selected from the listbox.
>>
>>If you don't mind, can you give me some pointers on what to code in the
>>function triggered during the onchange event. I just don't know how to
>>use javascript to get some value from the database.
>>
>>TIA!
>>
>>-Karen
>>
>>Steve Kitchen wrote:
>>
>>
>>>Set your onchange event something like ..
>>>
>>>onchange="Product_onchange('{RowIDAttribute}'); return false;
>>>
>>>where RowIDattribute is embedded in the <TR> of the grid (check out the
>>>example pack EditableGridAddButton for how to set this up).
>>>
>>>Then in your Javascript 'Product_onchange' function
>>>
>>>
>>>function Product_onchange(RowID) {
>>>
>>> var val = eval("document.invoice.product_code_"+RowID+".value");
>>>//retrieves current value from grid field
>>>
>>>// do your changes here
>>>
>>> eval("document.invoice.description_"+RowID+".value =
>
> '"+rowdescrip+"'"); //
>
>>>will put rowdescrip into the description field on the grid
>>>
>>>
>>>I use this to update several fields, and have also combined it with a
>>>pop-up, and a server lookup function which doesn't refresh the page
>
> (jsrs),
>
>>>so it is possible, even if the code isn't very pretty :-)
>>>
>>>
>>>Regards,
>>>
>>>Steve Kitchen
>>>s.kitchen@burningfrog.be
>>>
>>>
>>>
>>
>
>
Steve Kitchen
Posted: 11/02/2003, 1:03 AM

Hi Karen,

The example is a bit tricky to understand, I guess ... and you certainly
need to do some hand-coding to get this to work.

I do have some code I can send you to show how I've made this work, but as
the code is part of a system that one of my clients is paying for, I'm
reluctant to post it publicly ...

If you could drop me your email address tos.kitchen@burningfrog.be I'll
send you some code with an explanation of how it works.

Regards,

Steve Kitchen


"Karen Tan" <architech@awes2001.com> wrote in message
news:bo2c2v$jtk$1@news.codecharge.com...
> Hi Steve,
>
> I've been reluctant to post this as I'm quite embarassed to say that
> after looking at the only sample I found on the site so many times, I
> still can't figure out what to do with the code. The sample that I've
> found is made up of 3 listboxes and I can't figure out how the form's
> controls (lstMake, lstModel, lstOptions) relate to the
> variables/functions in the code (makeList, modelList, optionsList).
>
> Furthermore, it all looks like php codes to me so should I be coding
> this in the code part of the CCS page or in the html? If you don't
> mind, do you have a sample to share? I've tried looking into the forum
> and other places but can't seem to find anything that I can understand.
> Sorry to be so ignorant. Really appreciate your help. TIA!
>
> -Karen
>
> Steve Kitchen wrote:
> > Hi Karen,
> >
> > I use jsrsClient & jsrsServer to perform the background lookups from the
> > database.
> >
> > You can pick the code up from sourceforge.net (just do a search for jsrs
> > ...).
> > The server & client modules should integrate without the need for any
> > changes if you're coding in PHP. (Smiply include the js module at the
top of
> > the html of any page that needs the function). If you put both modules
in
> > your CCS source folder, they should get published with your project.
> >
> > In my previous posting, replace the "// do your changes here" bit with
the
> > jsrs function to lookup the data you need from the database.
> >
> > There is a reasonable example of how to use the code supplied with jsrs,
so
> > you shouldn't have too many problems getting it to do what you want.
> >
> > The JavaScript necessary to poke the values back into the editablegrid
is
> > probably the ugliest part :-)
> >
> > If you're still lost, let me know & I'll see what I can do to help ...
> >
> > Regards,
> >
> > Steve Kitchen
> >s.kitchen@burningfrog.be
> >
> >
> > "Karen Tan" <architech@awes2001.com> wrote in message
> >news:bnqg1j$ln2$1@news.codecharge.com...
> >
> >>Hi Steve,
> >>
> >>I was trying to do a server lookup like what you've done but decided it
> >>was beyond me. I need to populate the textbox with the product
> >>description after the product has been selected from the listbox.
> >>
> >>If you don't mind, can you give me some pointers on what to code in the
> >>function triggered during the onchange event. I just don't know how to
> >>use javascript to get some value from the database.
> >>
> >>TIA!
> >>
> >>-Karen
> >>
> >>Steve Kitchen wrote:
> >>
> >>
> >>>Set your onchange event something like ..
> >>>
> >>>onchange="Product_onchange('{RowIDAttribute}'); return false;
> >>>
> >>>where RowIDattribute is embedded in the <TR> of the grid (check out the
> >>>example pack EditableGridAddButton for how to set this up).
> >>>
> >>>Then in your Javascript 'Product_onchange' function
> >>>
> >>>
> >>>function Product_onchange(RowID) {
> >>>
> >>> var val = eval("document.invoice.product_code_"+RowID+".value");
> >>>//retrieves current value from grid field
> >>>
> >>>// do your changes here
> >>>
> >>> eval("document.invoice.description_"+RowID+".value =
> >
> > '"+rowdescrip+"'"); //
> >
> >>>will put rowdescrip into the description field on the grid
> >>>
> >>>
> >>>I use this to update several fields, and have also combined it with a
> >>>pop-up, and a server lookup function which doesn't refresh the page
> >
> > (jsrs),
> >
> >>>so it is possible, even if the code isn't very pretty :-)
> >>>
> >>>
> >>>Regards,
> >>>
> >>>Steve Kitchen
> >>>s.kitchen@burningfrog.be
> >>>
> >>>
> >>>
> >>
> >
> >
>


   


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

Web Database

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.