#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Location
    nyc
    Posts
    57
    Rep Power
    0

    Error says "Variable OPTION is undefined"


    Hi,
    I am getting the error like "Variable OPTION is undefined"

    But i have defined OPTION in the previous form.

    In a nutshell, i am using updating and deleting sql statements in one template, for that I use OPTION.

    If i don't use the option, it works fine. But it takes the detele statement defaulty. So, please help me out from this.

    Thank you!
    Amudha.
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    On your action page, do:

    <cfdump var="#form#"><cfabort>

    and then run the code. This will dump everything in the form scope to the screen. Do you see the variable you are expecting? If not then something is wrong with your form.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Location
    nyc
    Posts
    57
    Rep Power
    0
    Thank you for your reply!

    It dumps for every page.. not for my particular page that i wanted to do.

    If i don't use OPTION, it works fine. But it takes the delete statement defaultly.

    I could understand that the problem would be from my SET OPTION only..

    Will you help me out from this!

    Amudha.


    Originally Posted by kiteless
    On your action page, do:

    <cfdump var="#form#"><cfabort>

    and then run the code. This will dump everything in the form scope to the screen. Do you see the variable you are expecting? If not then something is wrong with your form.
  6. #4
  7. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    Post your form code and the action page that the form posts to.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Location
    nyc
    Posts
    57
    Rep Power
    0
    It has many templates in my form..

    I have the problem from this point.. My code is..


    cfif IsDefined("Form.btnupdate")>
    <cfset Option = "UPD">

    <cfelseif IsDefined("Form.btndelete")>
    <cfset Option = "DEL">
    </cfif>

    <cfif OPTION IS ("UPD")>
    <cfquery name="UPD" datasource="pm">
    select * from con where concusid = '#Ncusid#' and conid= '#Nconid#'
    </cfquery>

    <cfoutput query="UPD">

    <form action="update_action.cfm" method="post">

    <table>
    <tr>
    <td>ConcusId :</td>
    <td><input type="text" name="concusid" value ="#Ncusid#" READONLY> </td>
    </tr>

    <tr>
    <td>ConId :</td>
    <td><input type="text" name="conid" value ="#Nconid#" READONLY></td>
    </tr>

    <tr>
    <td>Name :</td>
    <td><input type="text" name="name" value =#upd.connam# ></td>
    </tr>

    <tr>
    <td>Position :</td>
    <td><input type="text" name="position" value = #upd.conpos#></td>
    </tr>

    <tr>
    <td>Department:</td>
    <td><input type="text" name="condep" value = #upd.condep#></td>
    </tr>

    <tr>
    <td>Phone :</td>
    <td><input type="text" name="phone" value = #upd.conphn#></td>
    </tr>

    <tr>
    <td>Extension :</td>
    <td><input type="text" name="extension" value = #upd.conext#></td>
    </tr>

    <tr>
    <td>Email :</td>
    <td><input type="text" name="email" value = #upd.coneml#></td>
    </tr>

    <tr>
    <td>Email2 :</td>
    <td><input type="text" name="email2" value =#upd.coneml2#></td>
    </tr>

    <tr>
    <td>Fax :</td>
    <td><input type="text" name="fax" value = #upd.confax#></td>
    </tr>

    <tr>
    <td><input type="Submit" value="Update">
    <input type="reset" value="clear Form"></td>
    <tr>

    <tr>
    <td><input type ="Submit" value="Delete">
    <tr>

    </table>

    </cfoutput>
    </form>



    AND MY ACTION PAGE CODE IS :
    <CFIF OPTION IS ("UPD")>

    <cfquery name="updatecontact" datasource="pm"

    sql= "update con
    set
    connam ='#form.name#',
    conpos='#form.position#',
    condep='#form.condep#',
    conphn='#form.phone#',
    conext='#form.extension#',
    coneml='#form.email#',
    coneml2='#form.email2#',
    confax='#form.fax#'
    where concusid = '#form.concusid#'
    and conid = '#form.conid#'">
    </CFIF>

    <CFIF OPTION IS ("DEL")>

    <cfquery name = "deletecontact" datasource="pm"
    sql ="delete from con where concusid = '#form.concusid#' and conid = '#form.conid#'">
    </CFIF>

    <cfinclude template="info.cfm">



    Originally Posted by kiteless
    Post your form code and the action page that the form posts to.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Location
    nyc
    Posts
    57
    Rep Power
    0
    THE MAIN FORM CODE IS:

    <cfif Not Isdefined("Ncusid")><cfset #Ncusid# = ""></cfif>

    <cfset set1 = "select * from cus">

    <cfset set2="select cus.cusid, cus.cusnam, cus.cusadd, cus.cusadd1, cus.cuscty, cus.cusstt, cus.cuscny, cus.cusphn, cus.cusphn1, cus.cusfax, cus.cuswww,con.conid, con.concusid, con.connam, con.conpos,con.condep, con.conphn, con.conext, con.coneml, con.coneml2, con.confax from con, cus where con.concusid = cus.cusid and cus.cusid='#Ncusid#'">

    <cfset set3 = "select * from cus where cusid='#Ncusid#'">

    <cfquery name="getset1" datasource="pm">#PreserveSingleQuotes(set1)#</cfquery>

    <cfquery name="getset2" datasource="pm">#PreserveSingleQuotes(set2)#</cfquery>

    <cfquery name="getset3" datasource="pm">#PreserveSingleQuotes(set3)#</cfquery>

    <html>
    <title>
    Contact information page
    </title>

    <h2> Contact Information </h2>

    <form action="goandnew.cfm" method="post">

    Customer :
    <select name="Ncusid">
    <cfoutput><option value <cfif #Ncusid# is ""> selected </cfif> > Select a

    Customer </option> </cfoutput>
    <cfoutput query ="getset1">
    <option value=#GETset1.cusid# <cfif #GETset1.cusid# is #Ncusid#> selected

    </cfif> > #cusnam# </option>
    </cfoutput>
    </select>

    <input type="submit" name="btngo" value="go">
    <br> <br>
    <input type="submit" name="btnadd" value= "New Contact">

    </form>

    <br><br>

    <cfoutput>
    <table>
    <tr><td>Location :</td> <td> #getset3.cuscty# </td> </tr>
    <tr><td>Phone :</td><td> #getset3.cusphn# </td> </tr>
    <tr><td>Fax :</td><td> #getset3.cusfax# </td> </tr>
    <tr><td>Web :</td><td> #getset3.cuswww# </td> </tr>
    </table>
    </cfoutput>

    <table cellpadding="15" cellspacing="0" border="1">
    <tr>
    <th>connam</th>
    <th>condep</th>
    <th>conphn</th>
    <th>conext</th>
    <th>coneml</th>
    </tr>

    <cfoutput query="getset2">
    <form action = "updatecontact.cfm" method="post">
    <tr>
    <td>#connam#</td>
    <td>#condep#</td>
    <td>#conphn#</td>
    <td>#conext#</td>
    <td>#coneml#</td>
    <input type="hidden" name="Ncusid" value= "#cusid#">
    <input type="hidden" name="Nconid" value= "#conid#">
    <td><input type="submit" name="btnupdate" value="update"></td>
    <td><input type="submit" name="btndelete" value="delete"></td>
    </form>
    </tr>

    </cfoutput>
    </table>
    <cfdump var="#form#"><cfabort>
    </html>




    Originally Posted by kiteless
    Post your form code and the action page that the form posts to.
  12. #7
  13. Standing 3 feet to the left.
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2006
    Location
    USA
    Posts
    1,435
    Rep Power
    185
    Is all the code from one cfm page, or multiple ones?

    Also, which line is the error from? You have a lot of lines that use Option...

    If they are on different pages, or the Action Page code is seperated from the first set of code you posted (i.e., the first set is in a <cfif>, the second set is in a <cfelse> for that <cfif>), then the Action Page isn't getting the Option variable (assuming that's where the problem lies.)

    If that is the case, declaring the option variable either outside the <cfif> or as a session variable (depending on circumstances) could fix the problem.
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Location
    nyc
    Posts
    57
    Rep Power
    0
    YEP! you got it.. (from my first coding post!)

    I have another option like that for GO AND SEARCH..

    I want UPDATE(UPD) and DELETE (DEL) in the same page to use this OPTION METHOD...

    That's why problem begins...

    I am still working on this OPTION.. but no positive result!!

    Originally Posted by Tukaro
    Is all the code from one cfm page, or multiple ones?

    Also, which line is the error from? You have a lot of lines that use Option...

    If they are on different pages, or the Action Page code is seperated from the first set of code you posted (i.e., the first set is in a <cfif>, the second set is in a <cfelse> for that <cfif>), then the Action Page isn't getting the Option variable (assuming that's where the problem lies.)

    If that is the case, declaring the option variable either outside the <cfif> or as a session variable (depending on circumstances) could fix the problem.
  16. #9
  17. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    OK I'm afraid I opened a can of worms. I don't have time to look at the code in detail becuase to be honest there is simply too much there and what is there is too confusing.

    My advice would be to refactor your entire approach because this is just way too convoluted. Trying to maintain this going forward will be a nightmare.

    Can you describe as briefly as you can exactly what you are trying to do? Maybe we can talk through a better approach.
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Location
    nyc
    Posts
    57
    Rep Power
    0
    In my form, everything works fine. But for one! that is,

    I am trying to do two action page's sql statements in one template with use of CFIF OPTION that's it.

    Thanks kateless!

IMN logo majestic logo threadwatch logo seochat tools logo