Welcome to Dream.In.Code
Getting Help is Easy!

Join 95,475 Programmers for FREE!. Ask your question and get quick answers from Dream.In.Code experts. There are 968 online right now! We're the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a Expert

Register to Make This Box Go Away!


Displaying array/loop data

 
Reply to this topicStart new topic

Displaying array/loop data, Trying to output data from an array onto the form

bruce779
post 18 Feb, 2008 - 04:26 AM
Post #1


New D.I.C Head

*
Joined: 29 May, 2007
Posts: 13


My Contributions


Hi guys, thanks for looking in.
The problem I'm having is this:
The user selects an item from a select list.
If certain conditions are met the item selected appears in a field further down the form.

I have a javascript array that is populated with all the options that might appear in the select.
The array also hold values for issue_reqd and expiry_reqd. If these 2 values are Y (for the selected item) then I want the item to appear in the text field further down. If only 1 or 0 values are Y then do nothing.

Here is my code:
Array:
CODE
var flagArray = new Array();        
        <cfloop query="qryIssueReqdFlags">
            <cfoutput>
                flagArray[#currentRow#] = new Array();

                flagArray[#currentRow#][1] = '#description#';
                flagArray[#currentRow#][2] = '#issReqd#';
                flagArray[#currentRow#][3] = '#valid_days#';
                flagArray[#currentRow#][4] = '#expiryRequired#';
            </cfoutput>
            <!--- <cfset variables.showTitle = true> --->
        </cfloop>


the array is fine, all elements are populated correctly.

Function to populate text field:
CODE
function showProofBlock(obj, loop)
    {
        for (y=1; y <=flagArray.length-1; y++)
        {
            if(flagArray[y][1] == obj.value)
            {
                if(flagArray[y][2] == 'Y' && flagArray[y][4] == 'Y')
                    {
                        document.getElementById('showProvidedProofs_'+loop).style.display = 'block';
                        document.getElementById('providedProof_'+loop).value = obj.value;
                    }        
            }
        }    
    }


Select List:
CODE
<cfoutput>
        <select style="width: 250px" name="disabilityProofType_#DisLoopCount#" id="disabilityProofType_#DisLoopCount#" onMouseOver="window.status='Customers Disability Proof Type'" onchange=showProofBlock(this, #DisLoopCount#);">
                <option value="0"></option></cfoutput>
                <cfset variables.qryDisabledProofType=application.concTravelAppValidation.getDisabledProofType(#personalStatusArray[#DisLoopCount#][1]#,application.urlDecrypt(variables.cot_id))>
        <cfoutput query="qryDisabledProofType">
          <option value="#qryDisabledProofType.description#">#qryDisabledProofType.description#</option>
    </cfoutput>
</select>


Text Field:
CODE
<cfoutput>
        <div id="showProvidedProofs_#DisLoopCount#" style="display: none;">
            <td style=" padding-left: 12px;" width="400px">
                <input type="hidden"
                readonly="true"
                name="providedProof_#DisProofLoopCount#"
                id="providedProof_#DisProofLoopCount#"
                class="displayInput"
                onMouseOver="window.status='Customers provided proof type'"
                value="">
            </td>
        </div>
    </cfoutput>


hope this is clear enough.
Thanks again for looking.

Bruce


--------------------
IPB Image
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 7/5/08 03:43AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month
-->