Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Edit page containing DropDowns 1

Status
Not open for further replies.

needahand

IS-IT--Management
Dec 7, 2011
4
0
0
GB
Good afternoon,

I have 3 tables in a database called Invoicing. The main table is called MonthlyCharges and contains fields such as MonthlyChargesid, client (which relates to a field ClientID in the 2nd table called ClientTable and contains fields such as ClientID, ClientName, ClientDetails etc), unit (which relates to unitID in the Units table which contains fields such as UnitID, UnitName etc), Amount etc.

When a new record is created, I want the person adding a new record to be able to select from dropdowns for the clients and units, populated by queries for the 2 other tables. When editing, the same dropdowns will appear and selected on the item which was selected when the record was created.

This is an example of the code in the edit page; I don't know how to write the CFIF code which would select in a dropdown the chosen client and then send the relevant clientid to write to the database in the ation page.

<cfoutput query="UpDateclient">
<cfform action="update_action.cfm" method="Post">
<tr>
<td>ID </td>
<td><cfinput name="ClientMonthlyCharge_ID" type="hidden" value="#ClientMonthlyCharge_ID#" size="50"></td>
</tr>
<tr>
<td>Contact Name </td>
<td><cfinput name="ContactName" type="text" value="#ContactName#" size="50"></td>
</tr>
<tr>
<td width="111">Rate</td>
<td width="457"> <cfinput type="Text" name="Rate" value="#Rate#" size="50"></td>
</tr>
<tr>
<td>Rate Unit</td>
<td> <cfinput type="Text" name="RateUnit" value="#RateUnit#" size="50"></td>
</tr>
<!--<tr>
<td>Client</td>
<td> <cfinput type="text" name="Client" value="#Client#" size="50"></td>
</tr>-->

<tr>
<td>&nbsp;</td>
<td><cfinput type = "submit" name="update" class="button" value = "Update"
onClick="return confirm('Are You Sure You Want To Update This Record?');"></td>
</tr>
</cfform>
</cfoutput>

I hope this makes sense and thank you in advance for your help.

Many thanks.
 
I think you will need a query to get all the "active" clients. Then you can try the following

Code:
<cfoutput query="UpDateclient">
<form>
...
<tr>
	<td>Client</td>
    <td>
    <select name="client" id="client">
    	<option value="">select client</option>
        <cfloop query="getClients">
        <option value="#clientID#"<cfif getClients.clientID eq UpDateclient.clientID>selected="selected"</cfif>>#clientName#</option>
        </cfloop>
    </select>
    </td>
</tr>
...
</form>
</cfoutput>

By the way, I am not a big fan of cfinputs.

ColdFusion Ninja for hire.
 
Thanks FALCONSEYE for your help.

I have an action page which has been giving me the following error;

Error Executing Database Query.
[Macromedia][SQLServer JDBC Driver]Invalid parameter binding(s).

I have cut down the page to see why it is throwing up the error, until finally all I have left is;


<cfquery datasource="test">
UPDATE ClientMonthlyChargesTable
SET ContactName = <cfqueryparam value="#Form.ContactName#">
WHERE ClientMonthlyCharge_id = <cfqueryparam value="#Form.ClientMonthlyCharge_id#">
</cfquery>

Many thanks for your help in advance.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top