Skip to main content
Participant
June 27, 2006
Answered

Drop down list doesn't display selected value

Hi there,

I have a problem. This page output from the query result. There is 2 fields need to be updated:scholarshipID and amount. I want to update my query at once. My dynamic drop down list doesn't display selected value. The value is there but doesn't recognize it in the drop down list. I couldn't find the error. My code is below, so please help....

<cfquery name="getStudentsData" datasource="#application.DSN#">
select StudentID, fname, lname, GPA, Tbl_Students.ID, ScholarshipID, amount, Tbl_StudentsScholar.ID as SSID, AwardStatus
from Tbl_Students, Tbl_ApplyYear, Tbl_EduBckgrnd, Tbl_StudentsScholar
where Tbl_Students.ApplyYr = Tbl_ApplyYear.id
and Tbl_Students.id = Tbl_EduBckgrnd.SID
and Tbl_Students.ID = Tbl_StudentsScholar.SID
and ApplyYear = 1
and steps = 7
order by studentid
</cfquery>

<cfquery name="getScholarship" datasource="#application.DSN#">
select AcctNum, scholarship, Tbl_Scholarships.id, Code
from Tbl_Scholarships, Tbl_DistCode
where Tbl_Scholarships.DistCode = Tbl_DistCode.id
order by AcctNum
</cfquery>

<cfparam name="X" default="0">
<cfparam name="CounterX" default="0">

<!--- get scholarship --->

<cfif getStudentsDataRet.RecordCount eq 0>
<p class="paragraph">   No Records Found</p>
<p class="pageheight"></p>
<p class="pageheight"></p>
<cfelse>


<p class="submitmessage">   Records Found - <cfoutput>#getStudentsDataRet.Recordcount#</cfoutput></p>
<table width="98%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse" bordercolor="#000000" align="center">
<tr class="steptext2" bgcolor="#999999" align="center">
<td width="10%">Student ID</td>
<td width="9%">Last Name</td>
<td width="9%">First Name</td>
<td width="5%">GPA Cum</td>
<td width="5%">Account #</td>
<td width="5%">Amount</td>
<td width="20%">Account #|Dist Code|Scholarship Name</td>
</tr>

<form action="updateAward.cfm" method="post" name="AwardForm">
<cfoutput query="getStudentsDataRet">
<cfif x eq 0 and x neq getStudentsDataRet.recordcount>
<cfset x = 1>
<cfelseif x neq (getStudentsDataRet.recordcount +1)>
<cfset x = x + 1>
</cfif>
<tr class="paragraph">
<td>#StudentID#</td>
<td>#lname#</td>
<td>#fname#</td>
<td>#GPA#</td>


<cfif AwardStatus eq 2>
<cfquery name="getStudentsScholar" datasource="#application.DSN#">
select scholarship, Code, Tbl_Scholarships.id, AcctNum
from Tbl_Scholarships, Tbl_DistCode
where Tbl_Scholarships.DistCode = Tbl_DistCode.id
and Tbl_Scholarships.ID=#getStudentsDataRet.ScholarshipID#
</cfquery>
</cfif>
<td>
<select name="scholarshipID_#X#" onChange="showMessage_#X#(this.options[this.selectedIndex].value)">
<option value=""></option>
<cfloop query="getScholarshipRet">
<option value="#id#" <cfif getStudentsDataRet.ScholarshipID eq id>selected</cfif>>#AcctNum#</option>
</cfloop>
</select>
</td>
<td><input name="amount_#X#" type="text" size="5" <cfif amount gt 0>value="#NumberFormat(amount, 99.99)#"</cfif>/></td>
<td><cfif AwardStatus eq 2>#getStudentsScholar.AcctNum# | #getStudentsScholar.Code# | #getStudentsScholar.Scholarship# | #getStudentsDataRet.ScholarshipID#</cfif></td>
<input name="IndexID_#x#" type="hidden" value="#SSID#" />
</tr>
</cfoutput>
<cfoutput><input name="CounterX" type="hidden" value="#getStudentsDataRet.RecordCount#" /></cfoutput>
<tr>
<td align="center" colspan="11" height="50" valign="middle"><input name="Submit" type="submit" value="Submit" /></td>
</tr>
</form>
</table>
</cfif>
This topic is closed to new replies. Start a new post to keep the conversation going.
coderWilCorrect answer
Inspiring
June 28, 2006
syntax is : getStudentsDataRet.ScholarshipID[1]

where '1' is the row number you want to specify

6 replies

Inspiring
June 29, 2006
GiGi05,
You shoulda marked Dan as the 'answer man' for this one. He did the heavy lifting.
Translate
GiGi05Author
Participant
June 28, 2006
Thanks a million for all your help!!! Your comment is really appreciated.
Translate
Inspiring
June 28, 2006
Try setting a variable inside the query loop and using that to check the scholarshipid in the loop. Also try using the id from the student table to name the fields.
Translate
coderWilCorrect answer
Inspiring
June 28, 2006
syntax is : getStudentsDataRet.ScholarshipID[1]

where '1' is the row number you want to specify
Translate
GiGi05Author
Participant
June 28, 2006
How can i specifying a row number?
Translate
Inspiring
June 27, 2006
Here:
cfloop query="getScholarshipRet">
<option value="#id#" <cfif getStudentsDataRet.ScholarshipID eq id>selected</cfif>>#AcctNum#</option>
</cfloop>

Your cfif is probably never returning true. The fact that you are not specifying a row number for getStudentsDataRet.ScholarshipID could be significant.
Translate