EasyCFM.COM ColdFusion Forums / Coding Help! / Select option

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Select option -- page: 1 2

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

jampu
11-23-2005 @ 12:11 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 48
Joined: Jun 2005

<cfquery name="getpmm" datasource="dakcalender">
select id,firstname,lastname,email From engineering_packet_pmm order by firstname
</cfquery>
<select name="pmm">
<option value=""></option>
<cfoutput query="getpmm">
<option value="#email#">#firstname##lastname#</option>
</cfoutput>
</select>

After form is submitted through submit button
i want to check whether any select option is selcted or not.I have done checking
<cfif isdefined("form.submit")>
<cfif #1Form.pmm.Value# gt '>
<cfoutput>success</cfoutput>
</cfif>

But it is giving me error
Can anyone help me


JJfutbol
11-23-2005 @ 12:31 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 1250
Joined: Nov 2004

Hmm your cfif for testing if data is validated is missing a lot of code so I'm not sure if you copied and pasted but if so then thats the case. Also please share with us what your error actually was. You'd be amazed at how much that can help us solve your problem even quicker. Try this:

<cfif IsDefined("Form.Submit")>
      <cfif Len(Trim(Form.Pmm)) NEQ 0>
           You selected a value from the select list.
      <cfelse>
           You did NOT select a value.
      </cfif>
</cfif>

That should get your code working. Remember when using a select drop down by default it only returns one value so there is no need to test for it with .value (this ain't JavaScript;)). Also don't put pound signs where they aren't needed for example you don't need them in your cfif statement, makes for ugly code. Frown  Because a select only returns one value we just reference it as we would any other form variable, by its name.

Let me explain the code above. What its saying is trim any whitespace and then give me the length of the value selected in the drop down. If it has a length (anything but a length of 0 - NEQ 0) that means the user selected something (value="someone's email") if not then the else statement executes because there is a length of 0 (value=""). Hopefully this all makes sense. Good luck. Smile

----------------------------------------------------
Need FREE CF applications?? Then my site has it all, http://www.javier-julio.com/development/coldfusion/downloads/ In time I will be including many more free CF apps and ASP ones as well. Currently working on a fully accessible Forum, which validates as full CSS and XHTML 1.0 Strict. It will be open source and available to all.

jampu
11-23-2005 @ 12:52 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 48
Joined: Jun 2005

Error is
1Form," on line 480, column 16, is not a valid identifer name
The CFML compiler was processing:

an expression beginning with "1Form.pmm", on line 480, column 16.This message is usually caused by a problem in the expressions structure.
an expression beginning with "Trim", on line 480, column 11.This message is usually caused by a problem in the expressions structure.
an expression beginning with "Len", on line 480, column 7.This message is usually caused by a problem in the expressions structure.
a cfif tag beginning on line 480, column 2.
a cfif tag beginning on line 480, column 2.

My code is
<cfif IsDefined("Form.Submit")>
      <cfif Len(Trim(1Form.Pmm)) NEQ 0>
           <cfoutput>success</cfoutput>.
      <cfelse>
            <cfoutput>notsuccess</cfoutput>.  
      </cfif>
</cfif>
Still it is giving me above error


jampu

jampu
11-23-2005 @ 12:55 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 48
Joined: Jun 2005

Error is
1Form," on line 480, column 16, is not a valid identifer name
The CFML compiler was processing:

an expression beginning with "1Form.pmm", on line 480, column 16.This message is usually caused by a problem in the expressions structure.
an expression beginning with "Trim", on line 480, column 11.This message is usually caused by a problem in the expressions structure.
an expression beginning with "Len", on line 480, column 7.This message is usually caused by a problem in the expressions structure.
a cfif tag beginning on line 480, column 2.
a cfif tag beginning on line 480, column 2.

My code is
<cfif IsDefined("Form.Submit")>
      <cfif Len(Trim(1Form.Pmm)) NEQ 0>
           <cfoutput>success</cfoutput>.
      <cfelse>
            <cfoutput>notsuccess</cfoutput>.  
      </cfif>
</cfif>
Still it is giving me above error


jampu

JJfutbol
11-23-2005 @ 12:59 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 1250
Joined: Nov 2004

There is no such thing as 1Form. It has no meaning in ColdFusion and that is why its throwing that error. Just leave it as Form.Pmm and it will work trust me. Pmm is part of the Form scope so thats why you say Form.Pmm and not 1Form.Pmm. Make sense??

----------------------------------------------------
Need FREE CF applications?? Then my site has it all, http://www.javier-julio.com/development/coldfusion/downloads/ In time I will be including many more free CF apps and ASP ones as well. Currently working on a fully accessible Forum, which validates as full CSS and XHTML 1.0 Strict. It will be open source and available to all.

This message was edited by JJfutbol on 11-23-05 @ 12:59 PM

megan
11-23-2005 @ 1:00 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 2398
Joined: Jan 2003

Hi - variable names can't start with a number hth~ megan

We have art so that we shall not die of reality ~ Nietzsche

megan
11-23-2005 @ 1:01 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 2398
Joined: Jan 2003

sorry jj - didn't mean to step on your post, I must have been writing mine while you were posting yours - take care, megan

We have art so that we shall not die of reality ~ Nietzsche

JJfutbol
11-23-2005 @ 1:03 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 1250
Joined: Nov 2004

No you didnt at all, its great that you help out. By no means you are not intruding. Smile  I just hope that jampu understands that when you want to reference a form variable its in the Form scope and not 1Form as that is not a valid structure. Maybe why hes confusing that is because his form is set too name="1Form".

----------------------------------------------------
Need FREE CF applications?? Then my site has it all, http://www.javier-julio.com/development/coldfusion/downloads/ In time I will be including many more free CF apps and ASP ones as well. Currently working on a fully accessible Forum, which validates as full CSS and XHTML 1.0 Strict. It will be open source and available to all.

jampu
11-23-2005 @ 1:07 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 48
Joined: Jun 2005

Thanks a lot

You are correct im referring form variables to form name.



jampu

megan
11-23-2005 @ 1:12 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 2398
Joined: Jan 2003

you are very right about his confusion JJ - I just wanted to also point out NOT to make variable names starting with a number as this will also cause problems.  Hope you have a Happy Thanksgiving (what are you cooking? btw I can hardly wait for you to get your recipe section up as I have 3 6'4" sons who are always hungry and I like to make delicious meals for them :D - take care, Megan

We have art so that we shall not die of reality ~ Nietzsche

PAGE: 1 2
Sponsored By...
iOpenSoft, LLC is a Houston, Texas Advanced Technology Studio Specializing in Web Design, Web Development, iPhone App Development and Android App Development.