This topic is locked

Conditional Section

1/25/2008 9:58:15 PM
PHPRunner General questions
C
Christopher author

I have a form in which the user selects a test session as their first step. There is one specific test session that needs a special disclaimer they agree to. I thought I could just wrap this code in an {if} statement in the template. However, since they have just selected that value and it hasn't been saved, how would I test for it.
Let's say the field is State - how do I say {if $value = CA}blah blah blah{/if}.
Or am I going about this entirely the wrong way, always a strong possibility.
thanks!

J
Jane 1/28/2008

Hi,
use JavaScript to change field value dynamically on the add/edit page.

Here is a sample:

{literal}<script>

document.forms.editform.value_FieldName.onchange=function()

{

if(this.options[this.selectedIndex].value=='CA')

{

document.forms.editform.value_FieldName2.value='another value';

}

else

{

document.forms.editform.value_state.value='';

}

}

</script>{/literal}


You can add JavaScript code on the Visual Editor -> HTML mode.

C
Christopher author 2/14/2008

Hi,

use JavaScript to change field value dynamically on the add/edit page.

Here is a sample:
You can add JavaScript code on the Visual Editor -> HTML mode.


Jane, that is not quite what I am looking for. See this posting pls >

Link
I am declaring a value in a before display event

$smarty->assign("value_CombineID",$_REQUEST["CID"]);


If that value is 105 or 106, I need to display an entire section that contains two field values and some text. If those values are not present, then it wouldn't display. Seems quite logical I could do this based on the other post, but I am having trouble getting from the session id example to my variable.

J
Jane 2/15/2008

Hi,
try to add smarty tags ({$if $show_snippet} and {/if}) on the Visual Editor page as shown in the sample and use this code in the Before display event:

$var = $smarty->get_template_vars("value_CombineID");

if ($var==105 || $var==106)

$smarty->assign("show_snippet",true);

else

$smarty->assign("show_snippet",false);