Hmm...
Tried just about every suggestion, and nothing seems to be popping up as a
warning...the form just submits anyway.
I have written a dynamic form loops through a table and gets all of the
questions that appear for the form, then loops through various question
types to see what type of question it is. Then when a question of type
"state" is called, a dynamic drop down is generated with a unique question
id and a list of states to choose from.
The code I am using follows--which doesn't seem to work:
<CFFORM ACTION="pv_post.cfm" method="post" NAME="addcase">
<CFIF #sec_info.field_type_id# IS 7>
<cfquery name="get_states" datasource="#datasource#" dbtype="ODBC">
SELECT * FROM State_Table
ORDER BY State_ID
</cfquery>
<cfoutput>
<script language="JavaScript">
if (document.addcase.qu_#sec_info.cqid#.value == "void"){
alert("Pick a state!");
}
</script>
</cfoutput>
<cfoutput>
<select name="qu_#sec_info.cqid#">
</cfoutput>
<OPTION VALUE="void">SELECT STATE
<CFOUTPUT query="get_states">
<OPTION VALUE="#state#">#state#
</cfoutput>
</select>
</cfif>
<cfoutput><INPUT TYPE="hidden" NAME="question_list"
VALUE="#question_list#"></cfoutput>
<INPUT type="submit" name="insert" value="Continue »">
</CFFORM>
I can't seem to get the message to pop up, and it is driving me crazy. Am I
putting the javascript in the wrong place. It seems as though, since the
form is displayed on the fly that I need to keep the javascript near the
loop item, so that the dynamic form field name sits together with the
dynamic field. I just can't get the javascript to notice if I have or
haven't chosen the "void" value. The form just submits regardless.
Thanks again for all of the suggestions, so far.
Cheers,
Brandon
----- Original Message -----
From: "David Baskin" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, May 29, 2001 6:17 PM
Subject: RE: Silly Validation Question...
> Brandon, put your "pick a state" select option before your cfoutput on the
> state query. then, on submit of the form, do a check to see if the user
has
> not selected a state. i use a value of "void" in my boxes and then just do
a
> simple javascript check to see if the value of the select box is void. if
> so, throw an error. HTH.
>
> d
>
> example:
>
> cf:
> select name="state" size="1"
> option value="void" Select a State
> cfoutput query="states"
> option value="state_cd" #state_cd#
> /cfoutput
>
> javascript:
> if (document.yourformname.state.value == "void"){
> alert("Pick a state!");
> }
>
>
> -----Original Message-----
> From: Brandon Wood [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 29, 2001 2:13 PM
> To: CF-Talk
> Subject: Silly Validation Question...
>
>
> Hey,
>
> Does anyone have a good script or method of making a select box contain a
> value other than ""?
>
> I am working on a state drop-down in which the first selection is "Pick
> State" with a value of "".
>
> What I want to happen is for a javascript screen to pop up (or something
> like that--you know the usual CFFORM javascript validation) if a user
tries
> to submit the form without choosing a state that has a value. I have
seenm
> this used many times and even with CFSELECT form fields, but I am having
the
> worst time trying to implement this.
>
> I want to populate the CFSELECT with a query from a State_Table but do not
> want to store a state with a value of "" as not to populate a state field
> with NULL answer.
>
> Is there an OnError or someother Javanscript function that could make sure
> that a value other than "" was chosen and that the error message could be
> configurable. I know that this is so CF 101, but I have never had to do
> this and am pulling my hair out in anger.
>
> Thanks a ton,
> BW
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists