<!-- Sign up FORM -->
<cfoutput>
<form method="post" action="HomeShow_submit.cfm">
<input type="hidden" name="UserID" value="#RemoveChars(CGI.Auth_User, 1, Find('\', CGI.Auth_User))#">
<input type="hidden" name="Fname" value="#User.fname#">
<input type="hidden" name="Lname" value="#User.lname#">
<input type="hidden" name="Year" value="#DatePart('yyyy', Now())#">
<table width="600" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<th colspan="2" scope="col" class="Header" align="center">Home Show Sign Up Form</th>
</tr>
<tr>
<th align="left" class="red">Shifts</th>
<td><select name="ShiftsList">
<option value="" selected> ... select a Shift</option>
<cfloop query="ShiftsList">
<option value="#ShiftsList.ShiftDetails#">#ShiftsList.ShiftDetails#</option>
</cfloop>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" NAME="SubmitForm" value="Submit"></td>
</tr>
</table>
</form>
</cfoutput>
<cfquerydatasource="HomeShow" name="InsertHomeShow">
INSERT INTO HomeShow
(UserID,
Fname,
Lname,
Year,
ShiftID
)
VALUES
('#Form.USERID#',
'#Form.Fname#',
'#Form.Lname#',
'#Form.Year#'
?
)
</cfquery>
问题:这是我需要帮助的地方,假设我们选择值= 1的选项,即3月20日星期五上午10点到中午。我想在Insert语句中得到值,即1。那么我可以在Insert语句中写一下来获取该值。
答案 0 :(得分:1)
知道了!一些建议帮助我找到了答案!
<!--Form -->
<tr>
<th align="left" class="red">Shifts</th>
<td><select name="ShiftsID"> <cfloop query="ShiftsList">
<optio value="#ShiftsList.ShiftID#">#ShiftsList.ShiftDetails#</option>
</cfloop>
</select>
</td>
</tr>
<!-- Actionpage-->
<cfquery datasource="HomeShow" name="InsertHomeShow">
INSERT INTO HomeShow
(UserID,
Fname,
Lname,
Year,
ShiftID
)
VALUES
('#Form.USERID#',
'#Form.Fname#',
'#Form.Lname#',
'#Form.Year#',
'#Form.ShiftsID#'
)