• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Need Help to get value of selected item from Select Dropdown list in cfquery under insert query

New Here ,
Feb 05, 2015 Feb 05, 2015

Copy link to clipboard

Copied

Form:

<!-- 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>



ActionPage

-------------------

<cfquerydatasource="HomeShow"  name="InsertHomeShow">
INSERT INTO HomeShow
  VALUES
  ('#Form.USERID#',
  '#Form.Fname#',
  '#Form.Lname#',
  '#Form.Year#'
  ?

Question: This is where I need help, suppose we choose option with value =1 i.e. Friday March 20th 10.00 a.m to noon. I want to get value i.e 1 in Insert statement. So What I can write in side Insert statement to get that value. 


              )
</cfquery>

sofia.png

Views

2.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Feb 26, 2015 Feb 26, 2015

Copy link to clipboard

Copied

LATEST

Like you have with the other form objects you can just use #form.ShiftsList#. This will return whatever the select option was when the form is posted. If you want the actual date though you will have to put this in the value attribute.

<cfquery datasource="HomeShow"  name="InsertHomeShow">

  INSERT INTO HomeShow

  VALUES

  ('#Form.USERID#',

  '#Form.Fname#',

  '#Form.Lname#',

  '#Form.Year#',

   #form.ShiftsList#)

</cfquery>

I would recommend taking a look at cfqueryparam - ColdFusion, English documentation - Adobe Learning Resources as well to secure your sql.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation