![]() |
lefty 8/20/2016 |
I have a form that allows people to pre-register for an event, I need to hide the "pre-register" field if the "completed" field = Yes I know its a Javascript OnLoad event, but I can't get it to work var ctrl = Runner.getControl(pageid, "completed"); pageObj.hideField("register"); if (this.getValue() == "Yes"){ pageObj.hideField("register"); } else { pageObj.showField("register"); }
|
![]() |
lefty 8/20/2016 |
Your missing one line. var ctrlcompleted = Runner.getControl(pageid, 'completed'); var ctrlregister = Runner.getControl(pageid, 'register'); ctrlcompleted.on('change', function(e){ if (this.getValue() == 'Yes'){ ctrlregister.hide(); pageobj.hideField("register"); $("tr[data-fieldname='register']").hide(); }else{ } ctrlregister.show(); $("tr[data-fieldname='register']").show(); });
|
M
|
mhollibush author 8/20/2016 |
UPDATED 914 EST.
|
M
|
mhollibush author 8/20/2016 |
Believe me, I am extremely new to this.... Thank you for all your help <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=80118&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
|
![]() |
lefty 8/20/2016 |
Still didn't work.. I think this is where I am having issues: A visitor visits the view page, if the event is still available the pre-register field ( custom field ) will be visible, But if the Admin marks the event complete - the pre-register field will be hidden I need the Javascript to see if the field complete is "Yes" then don't show the pre-register field. There is no other function on the page as the "complete field" is stored "yes" in the database and not on the form
|
M
|
mhollibush author 8/20/2016 |
try this on view page on load javascript. var ctrl = Runner.getControl(pageid, "complete"); var ctrl = Runner.getControl(pageid, "register"); if(ctrl.getValue() != "Yes"); // use proper case pageObj.hideField("register"); if (this.getValue() !== "Yes"){ pageObj.showField("register") } else { pageObj.hideField("register"); } IF complete field is not available then you need to grab it in either an inner join on the table you are working on . or before process event with a session variable. OR if complete is available on your table just add it to the view page and let the javascript decide weather to show or hide.
|
![]() |
lefty 8/20/2016 |
Making some headway - the field has been hidden, but it always hidden, whether "complete" is "Yes" or empty
|
![]() |
romaldus 8/21/2016 |
I have a form that allows people to pre-register for an event, I need to hide the "pre-register" field if the "completed" field = Yes I know its a Javascript onload event, but I can't get it to work var ctrl = Runner.getControl(pageid, "completed"); pageObj.hideField("register"); if (this.getValue() == "Yes"){ pageObj.hideField("register"); } else { pageObj.showField("register"); }
if ($values["completed"]=='YES') |
![]() |
lefty 8/21/2016 |
Great Suggestion romaldus . I don't think the completed registration value is available though . He needs to grab it either in query or in check for specific record and update on load. I was thinking the only way to this was query it with an alias or actual field value then javascript onload, but he still can do same with your short code which is a lot quicker and easier to code. |
M
|
mhollibush author 8/21/2016 |
The easiest way to do this is in php. In view page Before Display Event use the following code: if ($values["completed"]=='YES')
|
M
|
Mark Kramer 9/1/2016 |
Still didn't work.. I think this is where I am having issues: A visitor visits the view page, if the event is still available the pre-register field ( custom field ) will be visible, But if the Admin marks the event complete - the pre-register field will be hidden I need the Javascript to see if the field complete is "Yes" then don't show the pre-register field. There is no other function on the page as the "complete field" is stored "yes" in the database and not on the form
|