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