Focal Point
[SOLVED]How to supply null values for the checkbox control

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/4507018776

August 13, 2015, 11:07 AM
Rifaz
[SOLVED]How to supply null values for the checkbox control
Hi

I have a scenario where I need to pass the dates, other paramter values from Htmlpage1 to report1 and from report1, again it will drilling down to the detail report named report2. Remember, when passing to report2, it has to hold the paramter values from Htmlpage1 and report1. I do see quite a few posts similar to this and come up with the below code.

Actually, I got stuck up passing the null values when checkbox is not checked.

Htmlpage1 developed using Composer

report1
TABLE FILE CAR
PRINT COUNTRY CAR  
COMPUTE REC_COUNT/I5 = REC_COUNT + 1; NOPRINT
COMPUTE AREC_COUNT/A5 = EDIT(REC_COUNT); NOPRINT
COMPUTE CTRYFLD/A100 = '<input type="checkbox" name=CAR' | AREC_COUNT |' value="' | CAR | COUNTRY | '">';
BY COUNTRY NOPRINT
ON TABLE HOLD AS CAR_HOLD FORMAT HTMTABLE
END

-HTMLFORM BEGIN
<HTML>
<BODY>
<FORM name="wform" action='/ibi_apps/WFServlet' method="get">
<INPUT type="hidden" name="IBFS1_action" value="RUNFEX"/>
<INPUT type="hidden" name="IBFS_path" value="/WFC/Repository/WSX/testrifaz.fex"/>
!IBI.FIL.CAR_HOLD;
<input type=hidden name=howmany value=&LINES>
<INPUT type="submit" value="Run Report" target="_blank">
</FORM>
</BODY>
-HTMLFORM END
-EXIT
  


report2
 
testrifaz.fex
=============
-TYPE &CAR00001
-TYPE &CAR00002
:
:
-TYPE &CAR00010
-TYPE &howmany

  


How to tell &CAR000xx to pass value as ' ' when the checkbox is not checked.?

This message has been edited. Last edited by: Rifaz,


-Rifaz

WebFOCUS 7.7.x and 8.x
August 13, 2015, 12:15 PM
Tony A
HTML checkbox names and values do not get passed if they are not checked, so you have a couple of options.

I would be inclined to add an ID attributes to the form object to make it easier to obtain the form action attribute to begin the build of your URL.
Every other input can stay with just the name attribute. You can pull these into an array and append them to the URL depending upon whether they are hidden, checked checkboxes or unchecked checkboxes.

This is a quick piece of code which will give you an idea.
TABLE FILE CAR
PRINT COUNTRY CAR  
COMPUTE REC_COUNT/I5 = REC_COUNT + 1; NOPRINT
COMPUTE AREC_COUNT/A5 = EDIT(REC_COUNT); NOPRINT
COMPUTE CTRYFLD/A100 = '<input type="checkbox" name=CAR' | AREC_COUNT |' value="' | CAR | COUNTRY | '" />';
BY COUNTRY NOPRINT
ON TABLE HOLD AS CAR_HOLD FORMAT HTMTABLE
END

-HTMLFORM BEGIN
<html>
<head>
<script>
function build_url() {
  var objForm = document.getElementById("wform");
  var WF_URL  = objForm.action + "?";
  var arrInputs = document.getElementsByTagName("input");
  for (x=0; x<arrInputs.length; x++) {
    if (arrInputs[x].type === "checkbox" && arrInputs[x].checked) {
      WF_URL += "&" + arrInputs[x].name + "=" + arrInputs[x].value;
    } else {
      if (arrInputs[x].type === "checkbox") {
        WF_URL += "&" + arrInputs[x].name;
      } else {
        WF_URL += "&" + arrInputs[x].name + "=" + arrInputs[x].value;
      }
    }
  }
  window.open(WF_URL, "_blank" , "width=750,scrollbars=yes,resizable=yes, top=230, left=180, height=600"); 
}
</script>
</head>
<body>
<form id="wform" name="wform" action='/ibi_apps/WFServlet' method="get">
<input type="hidden" name="IBFS1_action" value="RUNFEX" />
<input type="hidden" name="IBFS_path" value="/WFC/Repository/WSX/testrifaz.fex" />
!IBI.FIL.CAR_HOLD;
<input type="hidden" name="howmany" value=!IBI.AMP.LINES;>
<input type="button" onclick="build_url();" value="Run Report" target="blank">
</form>
</body>
</html>
-HTMLFORM END


T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
August 13, 2015, 02:19 PM
Rifaz
I was coming home on a car, saw the email someone responds to my query and shows up your name, I was pretty confident, going to see the solution. Focal point should have a Like button.
I will try out in real-time tomorrow and post here.

Thanks Tony Music


-Rifaz

WebFOCUS 7.7.x and 8.x
August 17, 2015, 11:22 PM
Rifaz
It works with a little tweaks.


-Rifaz

WebFOCUS 7.7.x and 8.x
August 18, 2015, 03:54 AM
Wep5622
I'm not sure why you generate checkboxes with multiple names?

If you all give them the same name (say "CAR"), you get an amper-variable containing an array of the values that were checked, which is often what you need.

You can loop over the array using something like:
-DEFAULT &CAR0 = 1;
-TYPE Car 1: &CAR
-REPEAT :NEXTCAR FOR &C FROM 2 TO &CAR0;
-TYPE Car &C|: &CAR.&C
-:NEXTCAR



WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
August 18, 2015, 05:11 AM
Rifaz
 COMPUTE CTRYFLD/A100 = '<input type="checkbox" name=CAR
' | AREC_COUNT |'
 value="' | CAR | COUNTRY | '" />';


I tried with simple CAR as a variable name but when building the URL to call another fex, it simply forms as &CAR.

May be, I am not able to follow up your suggestion. If you don't mind, can you please edit my complete code and post back.


-Rifaz

WebFOCUS 7.7.x and 8.x
August 18, 2015, 06:28 AM
Wep5622
quote:
Originally posted by Rifaz:
I tried with simple CAR as a variable name but when building the URL to call another fex, it simply forms as &CAR.


It does show multiple checkboxes all named "CAR", right?
Then after it's been posted to the followup fex, the values are in an array.

Just printing &CAR fools you into thinking it's only a single value, as it only prints the first value in the array. In reality it's a list.
In that list, &CAR0 is the length of the list (say 'n') and &CAR1 to &CARn are the n values in the array. Hence the -REPEAT loop in my example. In this case, 'n' is the number of checked checkboxes (so <= 10).

There are a few things to take into account that you're probably going to run into:

This message has been edited. Last edited by: Wep5622,


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
August 18, 2015, 09:05 AM
Rifaz
quote:
It does show multiple checkboxes all named "CAR", right?

Yes, &CAR fools me, I knew about this but wouldn't strike in my mind after seeing the URL alert call.

I was writing a logic to append the zeros depends on the inputs but it is no more required, my lines of code now is reduced to 3 from 12 and it is much simpler to understand.
Thanks Wep5622 for looking into it even after posting as SOLVED.

I no need to worry about &CAR0 as I'm going to use &howmany to execute the loops anyhow. Actually, I'm writing the datas into the file and using the WHERE IN FILE in my final report.


-Rifaz

WebFOCUS 7.7.x and 8.x