Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Sep 2015
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    updating logic for text label

    I am trying to update the logic for the text label. Currently it displays Source (1), but I want it to just show Source not the (1) next to it, but when some clicks on the + Add Another Then the Label for the first SOW field shall show "(1)" next to the "Source" label. And the Label for the second SOW field shall show "(2)" next to the "Source" label And the Label for the Third SOW field shall show "(3)" next to the "Source" label and so on (max total five allowed).

    Also When The user on the "Finances" screen clicks on the "-Remove" link And removes all the SOW's except the first SOW Then the Label for the first SOW field shall not show "(1)" next to the "Source" label.

    How would I achieve this? This is the code I have so far,
    Code:
    <div class="col-xs-12 {{#i !== 0}}margin-top-wealthSource-br{{/}}">
        <br>
    </div>
    <div class="col-xs-12">
        <div class="row">
            <div class="col-xs-12 col-sm-6">
                <blueFieldGroup
                    id="otherSource-{{i}}"
                    groupType="styledselect vertical"
                    label="[[wealthSourcesLabel]] {{#wealthSourceId !== ''}}({{i + 1}}){{/}}"
                    styledSelectValue="{{wealthSourceId}}"
                    styledselect="[{
                        analyticsId: 'wealthDetails',
                        name: 'wealthDetails.{{i}}.wealthSourceId',
                        labelKey: 'label',
                        valueKey: 'value',
                        options:{{wealthSources}},
                        value:'{{wealthSourceId}}',
                        errorMessage: '{{v['wealthDetails' + i + 'wealthSourceId'].errorMessage}}',
                        addValidation: true,
                        rBlur: ['validateField','toggleError'],
                        rChange: ['changeWealthDetail', 'toggleError','formFieldTracking'],
                        rFocus:['formFieldTracking', 'toggleError', 'validateField'],
                        aria:{
                            selected:' current selection',
                            bottomOfMenu:' you have reached the bottom of the menu',
                            buttonLabel:'[[wealthSourcesLabel]] ({{i + 1}})',
                            describedByButton:'[[wealthSourcesLabel]] ({{i + 1}})',
                            listLabel:'[[wealthSourcesLabel]] ({{i + 1}})'
                        }
                    }]"
                />
            </div>
            {{#(wealthSourceId !== "" || wealthDetailId !== 0) && (wealthSources[0].value === '' || wealthDetailId !== 0)}}
                <div class="col-sm-6 util bottom left aligned">
                    <blueLink
                        id="deleteWealthDetailsLink-{{i}}"
                        classes="link-button"
                        content="[[deleteWealthDetailsLabel]]"
                        rClick="deleteWealthDetails"
                        adatext="[[wealthSourcesLabel]] ({{i}})"
                    />
                </div>
            {{/}}
        </div>
    </div>
    <!--Assets-->
    {{#if wealthSourceId === "ASSETS"}}
        {{>assets}}
    {{/if}}
    <!--Business-->
    
    <!--Employment-->
    
    <!--Inheritance-->
    {{#if wealthSourceId === "INHERITANCE"}}
        {{>inheritance}}
     {{/if}}
    <!--Sale-->
    {{#if wealthSourceId === "BUSINESS_SALE"}}
        {{>businessSale}}
    {{/if}}
    <!--Investments-->
    
    <!--Add another Button-->
    {{#if wealthDetails[wealthDetails.length - 1].wealthSourceId !== '' &&
        wealthDetails[wealthDetails.length - 1].wealthSourceId !== 'NONE' &&
        wealthDetails.length -1 === i &&
        wealthDetails.length < 5
    }}
        <div class="col-xs-12 margin-bottom-addWealthDetailsLink">
            <blueLink
                id="addWealthDetailsLink"
                analyticsId = "addWealthDetails"
                classes="link-button"
                content="[[addWealthDetailsLabel]]"
                rClick="addWealthDetails"
                adatext="[[addWealthDetailsAda]]"
            />
        </div>
    
    {{/if}}
    Everything works but I cant figure out how to not show the (1) when I add the first Source, It should only show "Source" but instead shows "Source (1)", that should show when I add a 2nd Source only, but then if i remove the 2nd Source, the first Source should go from "Source (1)" back to "Source"

  2. #2
    New to the CF scene
    Join Date
    Sep 2015
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anyone have an idea?

  3. #3
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Location
    Washington
    Posts
    6,792
    Thanks
    31
    Thanked 931 Times in 928 Posts
    Yes. Add the missing info.

    This is one of the new frameworks and a lot more stuff is needed for that to work.
    Evolution - The non-random survival of random variants.
    Physics is actually atoms trying to understand themselves.

  4. #4
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Location
    Washington
    Posts
    6,792
    Thanks
    31
    Thanked 931 Times in 928 Posts
    Here is an answer in straight javascript. This logic might help:
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title>New document</title>
    </head>
    <body>
    <div id="code"></div> 
    <button onclick="add();">Add Another</button>
    <button onclick="start();">Remove</button>
    
    
    <script>
    var n = 0;
    var place = document.getElementById('code');
    place.innerHTML = "Source : Text Label";
    
    function add(){
    	n++;
    	if(n <= 5){
    		if(n == 1){
    			place.innerHTML = "Source ("+n+") : Text Label";
    			n++;
    			place.innerHTML = place.innerHTML + "<br>Source ("+n+") : Text Label";
    		}else{
    			place.innerHTML = place.innerHTML + "<br>Source ("+n+") : Text Label";
    		}
    	}
    }
    function start(){
    	place.innerHTML = "Source : Text Label";
    	n = 0;
    }
    </script>
    </body>
    </html>
    Evolution - The non-random survival of random variants.
    Physics is actually atoms trying to understand themselves.

  5. #5
    New to the CF scene
    Join Date
    Sep 2015
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for this great piece of code, but unfortunatly I have to use our framework which is ractive.
    I think the only logic i have to modify is this line
    label="[[wealthSourcesLabel]] {{#wealthSourceId !== ''}}({{i + 1}}){{/}}"

    any ideas

  6. #6
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Location
    Washington
    Posts
    6,792
    Thanks
    31
    Thanked 931 Times in 928 Posts
    Sorry soupi, I work in raw javascript and a little in jquery. I think frameworks suck and stay away from them.

    Maybe someone else here will help.
    Evolution - The non-random survival of random variants.
    Physics is actually atoms trying to understand themselves.

  7. #7
    New to the CF scene
    Join Date
    Sep 2015
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i figured it out
    just changed logic to
    label="[[wealthSourcesLabel]] {{#if(wealthDetails.1)}}({{i + 1}}){{/if}}"


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •