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!

Action Forms

Status
Not open for further replies.

khurram

IS-IT--Management
Jan 10, 2001
95
0
0
CA
I would like to create an action form that allows editing on the same page. For example, you have all the inforamtion displayed as follows:

EmpID Employee Name Salary

Let say you have 10 employess listed where the Employee Name is hyperlinked. When you click on one of the names, the page loads again showing all the employees with the one selected being editable.

Once the changes have been made, the Update button is pressed and the page returns to normal.

Hope this is clear. Thanks.
 
I am not sure how to make the form make an item editable.
 
Is this what you're looking for? This assumes your hyperlink passes a variable called updateID which contains the employee's id (which I assume is unique).

Let me know if you have any problems as I put it together quickly.
GJ

<cfoutput query=&quot;empRecords&quot;>

<tr>
<cfif updateID is empID>
<form method=&quot;post&quot; action=&quot;update.cfm&quot;>
<td>#empID#</td>
<td><input type=&quot;text&quot; name=&quot;empName&quot; value=&quot;#empName#&quot;<</td>
<td><input type=&quot;text&quot; name=&quot;salary&quot; value=&quot;#salary#&quot;</td>
<td><input type=&quot;submit&quot; value=&quot;Update&quot;></td>
<input type=&quot;hidden&quot; name=&quot;updateID&quot; value=&quot;#updateID#&quot;>
</form>
<cfelse>
<td>#empID#</td><td>#empName#</td><td>#salary#</td><td></td>
</cfif>
</tr>

</cfoutput>
 
I don't how to implement this. The hyperlink containing the empid is on the same page. So, once the user click the hyperlink, the original page reloads and has everything the same except just shows the one item as editable.

I know what to do with the code you already provided but what do I reference in the hyperlink?
 
If the hyperlink will point back to the same page, just put this before the output query in my previous post.

<cfparam name=&quot;updateID&quot; default=&quot;&quot;>

This will ensure that no records are shown editable when the page first loads.

Then, change this section from above &quot;<td>#empName#</td>&quot; to this &quot;<td>
<a href=&quot;samePage.cfm?updateID=#urlencodedformat(empID)#&quot;>#empName#</a>
</td>&quot;. I think it will then do what you need after you change names to match your database and script names.

GJ
 
If you wanna make all that using one page, you can do that by checking if the submit button is exist or not. Take an example: (suppose that the following page is named 'mypage.cfm')

<cfif IsDefined(&quot;FormSubmit&quot;)>

<cfquery datasource=&quot;dsn&quot; name=&quot;name&quot;>
insert into table1 (first, last, age)
values ('#form.f_n#', '#form.l_n#', #form.age#)
</cfquery>

<cfelse>

<form action=&quot;mypage.cfm&quot; method=&quot;post&quot;>
First name: <input type=&quot;text&quot; name=&quot;f_n&quot;><br>
Last name: <input type=&quot;text&quot; name=&quot;l_n&quot;><br>
Age: <input type=&quot;text&quot; name=&quot;age&quot;><br><br>
<input type=&quot;submit&quot; value=&quot;save&quot; name=&quot;FormSubmit&quot;>
</form>

</cfif>


Take the idea and do the same for the update.
hope this will help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top