Page 1 of 1
Radio Button Groups and +Get
Posted: Fri Feb 27, 2015 5:44 am
by brett.elston
Hi,
I have a radio button group, with three values, and would like to use a button "onclick" event to run a crystal report passing this value as a parameter.
We already have this working with other reports and variables however the +get operation works with the specific field ID in those cases. Now however each radio button obviously has its own ID and the linking is done on the group field. How do I retrieve the group field value? What am I missing?
Your help would be much appreciated.
Thanks
FYI the current onclick event except the RBGROUPP parameter is not working:-
var command = "\\\\amasisprnsrv01\\CREXPORT\\crexport -u creps -p creps -f \\\\amasisprnsrv01\\crystal\\MROQT.rpt -e print -d S06D632P -s DATALIB -a WSDOC1A:"+get("WHQT1P")+" -a WSDOC2A:"+get("WHQT2P")+" -a WSMODE:"+get("RBGROUPP")+" -l";runPCCommand(command);
pui.click('ButPrintQt');
Re: Radio Button Groups and +Get
Posted: Fri Feb 27, 2015 3:14 pm
by Scott Klement
You can do this by checking the 'checked' and 'radioValue' properties of the widget object. For example, assuming you have 3 radio buttons with ids of "rb1", "rb2" and "rb2" (that are all bound to the same radio button group, "RBGROUPP") you can do this:
Code: Select all
var wsmode;
if (getObj("rb1").checked) wsmode=getObj("rb1").radioValue;
if (getObj("rb2").checked) wsmode=getObj("rb2").radioValue;
if (getObj("rb3").checked) wsmode=getObj("rb3").radioValue;
Now the 'wsmode' variable will have the value, and you can concatenate that into your PC command, or whatever you need to do with it.
Re: Radio Button Groups and +Get
Posted: Mon Mar 02, 2015 3:48 am
by brett.elston
Thank you Scott,
It's exactly what I was looking for and it works a charm.
Kind Regards
Brett
Re: Radio Button Groups and +Get
Posted: Thu Mar 05, 2015 7:23 am
by brett.elston
One more quick question please?
Using variable wsmode within the command worked perfectly. However now the requirement is to run separate reports based on the value of the variable.
I tried this below code:-
var wsmode;
var command;
if (getObj("PrtRb1").checked) wsmode=getObj("PrtRb1").radioValue;
if (getObj("PrtRb2").checked) wsmode=getObj("PrtRb2").radioValue;
if (getObj("PrtRb3").checked) wsmode=getObj("PrtRb3").radioValue;
if (getObj("PrtRb4").checked) wsmode=getObj("PrtRb4").radioValue;
if (wsmode="E") command="\\\\amasisprnsrv01\\CREXPORT\\crexport -u creps -p creps -f \\\\amasisprnsrv01\\crystal\\MROQT.rpt -e print -d S06D632P -s DATALIB -a WSDOC1A:"+get("WHQT1P")+" -a WSDOC2A:"+get("WHQT2P")+" -l";
if (wsmode="A") command="\\\\amasisprnsrv01\\CREXPORT\\crexport -u creps -p creps -f \\\\amasisprnsrv01\\crystal\\MROQTA.rpt -e print -d S06D632P -s DATALIB -a WSDOC1A:"+get("WHQT1P")+" -a WSDOC2A:"+get("WHQT2P")+" -l";
if (wsmode="1") command="\\\\amasisprnsrv01\\CREXPORT\\crexport -u creps -p creps -f \\\\amasisprnsrv01\\crystal\\MROQT1.rpt -e print -d S06D632P -s DATALIB -a WSDOC1A:"+get("WHQT1P")+" -a WSDOC2A:"+get("WHQT2P")+" -l";
if (wsmode="D") command="\\\\amasisprnsrv01\\CREXPORT\\crexport -u creps -p creps -f \\\\amasisprnsrv01\\crystal\\MROQTD.rpt -e print -d S06D632P -s DATALIB -a WSDOC1A:"+get("WHQT1P")+" -a WSDOC2A:"+get("WHQT2P")+" -l";
runPCCommand(command);
pui.click('ButPrintQt');
This however shows a warning in the onclick event screen, "assignment in conditional expression", and the value of command variable always set to the last value (if wsmode="D)
Really sorry, your js does not seem happy with the standard js { } (curly brackets) if/else logic. I did try that before hand and then resorted to this attempt.
Thanks
Re: Radio Button Groups and +Get
Posted: Thu Mar 05, 2015 1:19 pm
by Scott Klement
The syntax of your 'if' statements are wrong.
You have it like this:
Code: Select all
if (wsmode="E") ...do something...
It should be this:
Code: Select all
if (wsmode=="E") ...do something...
A single = means "assignment" (i.e. you are changing wsmode to "E"), whereas a double like == means "compare" (check if wsmode == "E"). You can also use three, like === to prevent Javascript from converting data types before making the comparison.
Really sorry, your js does not seem happy with the standard js { } (curly brackets) if/else logic. I did try that before hand and then resorted to this attempt.
Not sure what you mean by this. Which js do you mean by "your js"? The example I posted earlier doesn't use any { } or 'else' logic...?
Re: Radio Button Groups and +Get
Posted: Fri Mar 06, 2015 2:03 am
by brett.elston
Thank you Scott,
The "==" was staring me right in the face and I couldn't see it.
When I refer to "Your" I meant Profound and not your example specifically.
Regards