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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFOUTPUT/CFSELECT Problem (I think) HELP!!! 1

Status
Not open for further replies.

JulieM

Programmer
Jun 6, 2001
25
GB
I've created an update form to update my record as I need a select control within my form I have had to use CFSELECT as using the HTML SELECT does not work as I cannot nest the CFOUTPUT tag. Unfortunately this means I cannot stop the form submitting before all fields have been completed if someone presses the enter button. Can anyone help?



 
Hi Julie,

Are you asking how to stop a form from being submitted if all of the inputs haven't been completed? If so, the most common approach is to use Javascript to check all of the inputs when the enter button is clicked and only submit the form if they have. For this, I would suggest checking out the Javascript forum. The other approach is to have the action script check all of the inputs and re-display the form with all of their previous input and high-light fields which were not completed. Imo, you should do this even if you use JS as this keeps the visitor from submitting the form if they turn off JS.

Hope this helps,
GJ
 
Julie:

If you want to use a regular HTML select element but can't nest cfoutput tags, try closing the cfoutput right before your form's select element and then reopening the cfoutput tag right after the select element. Result would be no nesting.

Like this:


<form action=&quot;....>
<table ....>
<cfoutput>
<tr><td><form input type=&quot;text&quot; ...></td></tr>
</cfoutput>

<tr><td>
<select name=&quot;name&quot;>
<cfoutput query=&quot;get_select_values&quot;>
<option>#get_select_values.value#
</cfoutput>
</td></tr>

<cfoutput>
<tr><td><form input type=&quot;text&quot; ...></td></tr>
</cfoutput>
</table>
</fotm>


 
use cfloop instead of cfoutput....then no problem with nesting.

<cfoutput>
<form action=&quot;....>
<table ....>

<tr><td><form input type=&quot;text&quot; ...></td></tr>


<tr><td>
<select name=&quot;name&quot;>
<cfloop query=&quot;get_select_values&quot;>
<option>#get_select_values.value#
</cfloop>
</td></tr>


<tr><td><form input type=&quot;text&quot; ...></td></tr>

</table>
</fotm>
</cfoutput>

Cheers!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top