Jump to content

States dropdown if else statement needed, pls


payless4domains

Recommended Posts

Hi Guys,

 

My issue is the states dropdown menu on the vieworders page. not an issue I just need it to be able to display a new option further down the page depending on the original option selected before the form has been submitted.

 

i.e dropown

 

<div class="form-group">
<label for="inputState" class="col-md-4 control-label">{$LANG.clientareastate}</label>
<div class="col-md-8">
<input type="text" name="state" id="inputState" value="{$clientsdetails.state}" class="form-control"{if $loggedin} disabled="disabled"{/if} />
</div>
</div>

 

States - Queensland

- NSW

- ETC

 

What I'm trying to achieve is:

If a client selects value "Queensland" I need a new custom field to show further down the page, that relates to Queensland

If a client selects value "NSW" I need a different custom field to show in the same spot further down the page.

 

I've tried:

{foreach $values as $value}

{if $value = "Queensland"}
    Queensland
{elseif $value = "NSW"}
    do action
{elseif $value = c}
    do action
{/if}

{/foreach}

 

This is the code that goes down the page for "Queensland", but now needs to link to "Queensland" when selected and then there will be others for the other selections, I just can't get my head around how I can link via selection without sumbiting the form and then using the clientsdetails.state

{if $loggedin}
						<div class="line-padded" style="float:right;">
						<div class="col-md-12">
						<input type="checkbox" name="ctp" id="ctp" value="{$clientsdetails.customfields21}" checked>
						 Yes, Transfer my CTP insurance to RACQ
						</div>
						</div>
					{/if}



						{foreach key=num item=customfield from=$customfields}
							{if $customfield.name eq "CTP Insurance"}
							<div class="line-padded" style="float:right;>
							<div class="col-md-12">
							<div class="control">{$customfield.input|replace:'>':"checked>"}
							 Yes, Transfer my CTP insurance to RACQ
							</div>
							</div>
							</div>
							{/if}
						{/foreach}

 

another way to explain what I am trying to do: (doesn't work though}

{if $clientsdetails.state eq selected "Queensland"}
show the Queensland tickbox above
{elseif $clientsdetails.state eq selected "NSW"}
then show the NSW tick box
{elseif .... etc}
another tick box
{/if}

 

Really appreciate your help in advance.

 

Thanks Kev

Link to comment
Share on other sites

  • 3 weeks later...

Thank you and got this one solved. but again it does work when logged in.

 

<script>
$(function() {
   $("#stateselect").on("change",function() {
      $(".hideable").hide(); 
      var id = "#state"+(this.selectedIndex+1);
   $(id).show();
   }).change();
});
</script>

<style>
.hideable { display:none }
</style>

<div id="state1"></div>
<div id="state2" class="hideable">
{foreach key=num item=customfield from=$customfields}
{if $customfield.name eq "ACT"}
<div class="panel input-panel authorisation">
	<div class="panel-input">
	{$customfield.input}
	</div>
</div>
{/if}
{/foreach}
</div>

 

Thanks again Guys

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated