Hi,
I have the following code:
There will be as many hidden fields as the number of rows retrieved by the
query "getCities". Each is distinguished with the value of level_detail_uid for
each loop.
city.cfm
----------------
<html>
<head>
<title>Update </title>
<script language="JavaScript">
function delete_city(level_detail_uid,city_id ,cnam)
{
if ( confirm("Are you sure to delete the pricing-information for " + city_id
+ " ?") )
{
window.location = 'city_pricing_display.cfm?delete_level_detail_uid=' +
level_detail_uid +
'&delete_city_name=' + city_id + '&del_cnam=' + cnam;
}
}
<cfif isDefined("delete_level_detail_uid") and delete_level_detail_uid is
NOT "">
<cfoutput> #del_cnam#</cfoutput>
<cftransaction>
</cfquery>
</cfif>
</cftransaction>
</cfif>
<form method="POST" name="city_details" action="city_update_pop.cfm">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td>
<cfquery name="getCities" datasource="#application.alcdatasource#">
SELECT city_name, dtl.level_detail_uid,
FROM alc_pricing_level_details dtl, alc_city c, alc_detail_provider prvdr
WHERE level_desc_uid = #level_desc_uid#
AND dtl.level_detail = c.city_id(+)
AND prvdr.level_detail_uid = dtl.level_detail_uid
ORDER BY upper(city_name)
</cfquery>
<cfloop query="getCities">
<cfoutput>
<input type="hidden" name="cityname_#level_detail_uid#"
value="#getCities_city_name#">
</cfoutput>
<td>
<a
href="JavaScript:delete_city('#level_detail_uid#','#city_id#','#form.cityname_#l
evel_detail_uid##')" class="PageInnerNavigationHeadingSmall">Delete City</a>
</td>
</table>
</body>
</form>
</html>
------------------------------------------------------
Suppose the level_detail_uid is 12345.
After executing this it says
"element cityname_ is undefined in form
Please kindly help.....
Thanking in advance....
Regards,
Aswathy.
jdeline - 29 Jun 2007 16:14 GMT
Post the actual error message and the lines of code it refers to.
cf_matt - 29 Jun 2007 16:30 GMT
I think it must be this line
<a
href="JavaScript:delete_city('#level_detail_uid#','#city_id#',[b]'#form.cityname
_#level_detail_uid##')"[/b] class="PageInnerNavigationHeadingSmall">Delete
City</a>
It might have to be #evaluate("form.cityname_" & level_detail_uid)#
although i can see a number of problems in this code.
cf_dev2 - 29 Jun 2007 19:00 GMT
I agree with cf_matt. There are several problems with the code. The field
form.cityname_#level_detail_uid# won't exist when the form is first loaded. So
you can't use it in your link unless you define a default value first
<a
href="JavaScript:delete_city('#level_detail_uid#','#city_id#','#form.cityname_#l
evel_detail_uid##')" >...</a>
Also, the syntax to retreive the value is wrong. Assuming the variable is
defined, try using array notation
#form["cityname_#level_detail_uid#"]#