Connecting Tech Pros Worldwide Help | Site Map

Element PARTNO is undefined in URL

Newbie
 
Join Date: Dec 2007
Posts: 3
#1: Dec 20 '07
Hi, I am looking for some help with my code. Unable to get the action code to work.

Here is my code:
Expand|Select|Wrap|Line Numbers
  1. <head>
  2.     <title>Update Form Application</title>
  3.        <link rel="stylesheet" type="text/css" href="general.css" />
  4. </head>
  5.  
  6. <body>
  7.       <h2>Update Form Application </h2>
  8.         <a>Edit Component Number:  </a><cfoutput>#compno#</cfoutput> <a>for Product Number: </a><cfoutput>#prodno#</cfoutput>
  9.         <br></br>
  10.         <a>Current Part Number:  </a><cfoutput>#partno#</cfoutput> <a>Part Description: </a><cfoutput>#partdesc#</cfoutput>
  11.         <br></br>
Expand|Select|Wrap|Line Numbers
  1.         <cfparam name="Form.compno" default="0" type="numeric">
  2.         <cfparam name="partno" default="0" type="numeric">
  3.  
  4. <!--- Block One: Update Action Code --->
  5.  
  6. <cfif IsDefined("Form.update")>
  7.                 <cfquery name="updateComponent"
  8.                 datasource="#Request.DSN#"
  9.                 username="#Request.username#"
  10.                 password="#Request.password#">
  11.                 update Component
  12.                 set
  13.                 partno = '#Form.partno#',
  14.                 nopartsreq = '#Form.nopartsreq#'
  15.                 where
  16.                 compno = '#compno#'
  17.                 </cfquery>
  18.  
  19.         <cflocation url="updatecomponent.cfm?=#Form.partno#" addToken="no">
  20.  
  21. <!--- Block Two : Display Editable Fields --->
  22.  
  23.         <cfelseif IsDefined("Form.display")>
  24.                 <cfquery name="getPartList"
  25.                 datasource="#Request.DSN#"
  26.                 username="#Request.username#"
  27.                 password="#Request.password#">
  28.                 select *
  29.                 from part
  30.                 order by partno
  31.                 </cfquery>  
  32.  
  33.                 <cfquery name="getComponent"
  34.                 datasource="#Request.DSN#"
  35.                 username="#Request.username#"
  36.                 password="#Request.password#">
  37.                 select nopartsreq, partno
  38.                 from component
  39.                 </cfquery>   
  40.  
  41.                 <table>
  42.                 <cfform action="updatecomponent.cfm" method="post">
  43.                         <tr>
  44.                         <th style="text-align: left">Update Part: </th>
  45.                         <td> 
  46.                         <select name="#partno#">
  47.                         <cfoutput query="getPartList">
  48.                         <option value="#partno#">#partdesc#</option>
  49.                         </cfoutput>
  50.                         </select>
  51.                         </td>
  52.                         </tr>
  53.                         <tr>
  54.                         <th>Enter Num Parts Req: </th>
  55.                         <td>
  56.                         <cfinput name="nopartsreq" type="text"
  57.                         value="#getComponent.nopartsreq#" size="3"
  58.                         maxlength="2"
  59.                         required="yes"
  60.                         message="The number of parts needed is required from 1 to 10.">
  61.                         </td>
  62.                         <td>
  63.                         <input type="hidden" name="prodno" value="#prodno#">
  64.                         <input type="hidden" name="compno" value="#compno#">
  65.                         <input name="submit" type="submit" value="Update Component" />
  66.                         </td>
  67.                         </tr>
  68.                 </cfform>
  69.                 </table>
  70.                 <!--- IsDefined(“Form.display”) --->
  71.  
  72.  
  73. <!--- Block Three : Redisplay Fields --->
  74.  
  75. <cfelseif Form.compno NEQ "0" OR IsDefined("URL.compno")>
  76.                 <cfquery name="getComponent"
  77.                 datasource="#Request.DSN#"
  78.                 username="#Request.username#"
  79.                 password="#Request.password#">
  80.                 select nopartsreq, partno
  81.                 from component
  82.         <cfif IsDefined("URL.compno")>
  83.                 Where compno = <cfqueryparam cfsqltype=”CF_SQL_VARCHAR” value="#URL.compno#">
  84.         <cfelse>
  85.                 Where compno = <cfqueryparam cfsqltype=”CF_SQL_VARCHAR” value="#Form.compno#">
  86.         </cfif>
  87.                 </cfquery>   
  88. <cfelse>
  89.                 Please select a component from a <a href=”showproducts.cfm”>product</a> first.
  90. </cfif>
  91.                 <h4>
  92.                 <a href="showcomponents.cfm?prodno=<cfoutput>#prodno#</cfoutput>">
  93.                 Choose another Component Number</a>&nbsp;&nbsp;|&nbsp;&nbsp;
  94.                 <a href="showproducts.cfm">Choose another Product</a>
  95.                 </h4>   
  96.                 <cfinclude template = "../footer.cfm">   
  97.     </body>
  98. </html>
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Dec 21 '07

re: Element PARTNO is undefined in URL


You're submitting the form using the POST method, so the form variables will be available via the 'form' struct, not 'url'.

You're not using url.partno, so where does this error occur?
Newbie
 
Join Date: Dec 2007
Posts: 3
#3: Dec 21 '07

re: Element PARTNO is undefined in URL


Quote:

Originally Posted by acoder

You're submitting the form using the POST method, so the form variables will be available via the 'form' struct, not 'url'.

You're not using url.partno, so where does this error occur?

Thanks for replying. I'm still confused. I don't see where I am using URL in the form. 'form' struct means #Form.variable# correct?

Sorry on the url.partno, came from other error msg as I am trying to figure this submitting form problem.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#4: Dec 22 '07

re: Element PARTNO is undefined in URL


Quote:

Originally Posted by jumbopillow

Thanks for replying. I'm still confused. I don't see where I am using URL in the form. 'form' struct means #Form.variable# correct?

Correct.

Let me try and get this correct. You're trying to get block 1 to work, correct?

In block 1, you have a query and then you relocate to "updatecomponent.cfm?=#form.partno#". If you want url.partno available on that page, you'll have to change that to "updatecomponent.cfm?partno=#form.partno#"
Newbie
 
Join Date: Dec 2007
Posts: 3
#5: Dec 25 '07

re: Element PARTNO is undefined in URL


Quote:

Originally Posted by acoder

Correct.

Let me try and get this correct. You're trying to get block 1 to work, correct?

In block 1, you have a query and then you relocate to "updatecomponent.cfm?=#form.partno#". If you want url.partno available on that page, you'll have to change that to "updatecomponent.cfm?partno=#form.partno#"

Hi acoder, Thanks. I figured it out.
Cheers!
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#6: Dec 26 '07

re: Element PARTNO is undefined in URL


I'm glad you managed to figure it out, but it might be helpful for anyone with a similar problem if you could post your solution.
Reply