Groups > IBM > Studio400 > Re: Initializing fields with a Javascript




Initializing fields with a Javascript

Initializing fields with a Javascript
Wed, 30 Jan 2008 07:53:57 -050
I have an application that in green screen form you would place an 'X' in 
the box you want to select.  You can only select one box, if you select more 
than one after you hit Enter an error message appears.  When I placed it on 
the web we made them appear as checkboxes.  Now if a user picks two boxes an 
error mesage displays and it appears the screen refreshes clearing the 
checkboxes, but in the background the fields that the boxes point to still 
both have X's in them.  Since the person who coded this did not use a 
subfile each box is it's own field.  I tried adding something to the
"Insert 
into script" portion of the DDS and that worked as long as all the fields 
were displayed.  It was & = ' ';.  There is a total of 7 possible 
options but sometimes only 5 or 6 may display.  This causes the application 
to remain on that screen when I used what is shown above.

I tried using the clearfieldvalue function on the field itself using the 
User Defined HTML for that field but that just displayed the words on the 
screen.  I figured I did someting wrong or what I wanted to do cannot be 
done from there.  The latest things I tried is to use the isFieldVisible 
finction but that hangs if only 6 fields are shown instead of 7.  I have 
included what I am using now below.

if (FORMAT08.isFieldVisible("MNOR01")) {& = ' ';}

Any suggestions would be appreciated.  Thanks in advance.

Mark 

Post Reply
Re: Initializing fields with a Javascript
Fri, 01 Feb 2008 14:36:56 -050
Mark Giordano wrote:
> I have an application that in green screen form you would place an 'X' in 
> the box you want to select.  You can only select one box, if you select
more 
> than one after you hit Enter an error message appears.  When I placed it on

> the web we made them appear as checkboxes.  Now if a user picks two boxes
an 
> error mesage displays and it appears the screen refreshes clearing the 
> checkboxes, but in the background the fields that the boxes point to still

> both have X's in them.  Since the person who coded this did not use a 
> subfile each box is it's own field.  I tried adding something to the
"Insert 
> into script" portion of the DDS and that worked as long as all the
fields 
> were displayed.  It was & = ' ';.  There is a total of 7
possible 
> options but sometimes only 5 or 6 may display.  This causes the application

> to remain on that screen when I used what is shown above.
> 
> I tried using the clearfieldvalue function on the field itself using the 
> User Defined HTML for that field but that just displayed the words on the 
> screen.  I figured I did someting wrong or what I wanted to do cannot be 
> done from there.  The latest things I tried is to use the isFieldVisible 
> finction but that hangs if only 6 fields are shown instead of 7.  I have 
> included what I am using now below.
> 
> if (FORMAT08.isFieldVisible("MNOR01")) {& = ' ';}
> 
> Any suggestions would be appreciated.  Thanks in advance.
> 
> Mark 
> 
> 
Hi Mark,

My first thought was that what you really want to implement is radio 
buttons where only one can be selected at a time and if another one is 
selected the first selection is cleared.

To do a similar thing with check boxes could be done maybe by using some 
sort of backing db (arrays with the check box id, the field id and the 
state).  Then have each check box "register" when it is on the screen.

Setting the check box (is there something like onCheck ?) would cause a 
bit of javascript to run that would set the backing field values 
appropriately.

The clearing or registering (or whatever) could be done in HTML After 
Web setting for each check box field I think.  The User Defined HTML 
simply replaces the normal WF generated HTML for that field with 
whatever you specify. If you were just clearing the field then you'd 
likely want something like &.value = " ";  The &
should 
resolve into a javascript reference for field FIELD in the current record.

Post Reply
about | contact