Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form with Image Link/javascript issue

Status
Not open for further replies.

kory27

Technical User
Feb 28, 2008
13
US
Hi. I have two sets of code below. The first is part of my old code
off a page called item.cfm. the second is the same code, but i have
attempted to change the destination link to a url i have stored in my
database for the button btnaddtocart.gif. that db field is
#GetProduct.ProductLink#. the problem is when i change it, the link
doesn't show as that at all. Does anyone have any insight? this one is
above me. Thanks.

oh yeah, i would also like to do this for the button btnframeme.gif so
if what i would need to do is different, could you please let me know.
thanks again.

NEW Code Below

<p><span class="mediumbold">Quantity:</span>
<input type="text" name="q" value="1" size="1"
maxlength="2" class="small">
</p>
<p>
<a href="#GetProduct.ProductLink#"><img
src="images/btnAddtoCart.gif" border="0" alt="Click to buy #productname#
posters" hspace="2" /></a>
&nbsp;
<cfif GetProductMultiSize.RecordCount IS 0>
<cfif (GetProduct.productWidth LTE
application.MaxFrameWidth) AND (GetProduct.productHeight LTE
application.MaxFrameHeight)>
<input type="image"
onClick="javascript:document.frmItem.fa.value='frame'"
src="/images/btnFrameMe.gif" alt="Frame your #getproduct.productname#
poster here" border="0">
<br>


OLD CODE BELOW

<p><span class="mediumbold">Quantity:</span>
<input type="text" name="q" value="1" size="1"
maxlength="2" class="small">
</p>
<p>
<input type="image"
onClick="javascript:document.frmItem.fa.value='add'"
src="/images/btnAddToCart.gif" alt="Add #getproduct.productname# posters
to my shopping cart." border="0">
&nbsp;
<cfif GetProductMultiSize.RecordCount IS 0>
<cfif (GetProduct.productWidth LTE
application.MaxFrameWidth) AND (GetProduct.productHeight LTE
application.MaxFrameHeight)>
<input type="image"
onClick="javascript:document.frmItem.fa.value='frame'"
src="/images/btnFrameMe.gif" alt="Frame your #getproduct.productname#
poster here" border="0">
<br>
Framing starts at
<cfoutput>#DollarFormat(GetProduct.MINFRAMEPRICE)#</cfoutput>
</cfif><br>
 
What is the link in your new code when you run it? You mentioned it was incorrect. If you simply print GetProduct.ProductLink on the page does it show up as the correct URL?
 
it is actually the same exact url i am on, but on the end of it there is the #GetProduct.ProductLink#.
 
It actually says "#GetProduct.ProductLink#" in the URL? Try putting <cfoutput> tags around it so ColdFusion will interpret the code. That should do it for you. You might also want to view your HTML to make sure all of your CF code is being interpreted. Hope that was it!
 
Glowball,

Thanks for the attempt, but it didn't work. It actually made the button do nothing at all. So, i decided to try putting the same button with the link at the end of the page after the /form tag. It still did the same exact thing pointing to the link as if it were the same page. So then i took the button out and just put a link to words. same thing, with or without the cfoutput tags. I am putting the entire page code below. I am not very familiar with forms, but is there an area in dreamweaver where the form tag has a predefined url that all links from the form with the target=cart.cfm go to?

Again, thanks so much for your help.

<cfparam name="NavID" default="1">
<cfparam name="PNavID" default="0">
<cfparam name="p" default="0">
<cfif (p IS 0) OR (NOT IsNumeric(p))>
<cflocation url="cat_ap.cfm?NavID=1">
</cfif>
<cfif IsDefined("url.NID")>
<cfset NavID = #url.NID#>
</cfif>
<cfif IsDefined("url.PNID")>
<cfset PNavID = #url.PNID#>
</cfif>
<cfif NOT IsNumeric(NavID)>
<cflocation url="cat_ap.cfm?NavID=1">
</cfif>
<cfif NOT IsNumeric(PNavID)>
<cflocation url="cat_ap.cfm?NavID=1">
</cfif>

<!---
<cfset p=43195>
<cfset p=12508>
--->
<CFSTOREDPROC procedure="dbo.spProduct" datasource="Allposters3">
<CFPROCPARAM type="IN" dbvarname="@ProductID" value="#p#" cfsqltype="CF_SQL_INTEGER">
<CFPROCRESULT name="GetProduct">
</CFSTOREDPROC>
<cfif GetProduct.RecordCount IS 0>
<cflocation url="#cgi.http_referer#">
</cfif>
<cfif GetProduct.MultiSize GT 0>
<CFSTOREDPROC procedure="dbo.spProductMultiSize" datasource="Allposters3">
<CFPROCPARAM type="IN" dbvarname="@ProductID" value="#p#" cfsqltype="CF_SQL_INTEGER">
<CFPROCRESULT name="GetProductMultiSize">
</CFSTOREDPROC>
<cfelse>
<cfset GetProductMultiSize = querynew("dummy")>
</cfif>
<cfquery name="GetNavName" datasource="Allposters3" cachedwithin="#CreateTimeSpan(0,4,0,0)#">
SELECT NavName, NavMetaKeyword FROM tblNav WHERE (NavID=#NavID#)
</cfquery>
<cfquery name="GetNav" datasource="Allposters3" cachedwithin="#CreateTimeSpan(0,4,0,0)#">
SELECT ParentNavID, ParentName, ChildNavID, ChildName FROM dbo.tblNavigation_AP WHERE (ParentNavID=#NavID#)
</cfquery>
<cfquery name="GetNavRelated" datasource="Allposters3" cachedwithin="#CreateTimeSpan(0,4,0,0)#">
SELECT ParentNavID, ParentName, ChildNavID, ChildName FROM dbo.tblNavigation_AP WHERE (ChildNavID=#NavID#)
</cfquery>
<cfif Not GetNav.RecordCount>
<cfquery name="GetNav" datasource="Allposters3" cachedwithin="#CreateTimeSpan(0,4,0,0)#">
SELECT ParentNavID, ParentName, ChildNavID, ChildName FROM dbo.tblNavigation_AP WHERE (ParentNavID=#PNavID#)
</cfquery>
<cfquery name="GetNavRelated" datasource="Allposters3" cachedwithin="#CreateTimeSpan(0,4,0,0)#">
SELECT ParentNavID, ParentName, ChildNavID, ChildName FROM dbo.tblNavigation_AP WHERE (ChildNavID=#PNavID#)
</cfquery>
</cfif>
<cfquery name="GetNavRelCat" datasource="Allposters3">
SELECT NavID, NavName FROM dbo.qselNavRelatedCats WHERE ProductId = #p# ORDER BY NavName ASC
</cfquery>
<cfset I = ListFindNoCase(session.PHistName, GetProduct.productName,"~")>
<cfif I IS 0>
<cfset session.PHistName = ListPrepend(session.PHistName, GetProduct.productName,"~")>
<cfset session.PHistValue = ListPrepend(session.PHistValue, "item.cfm?#CGI.QUERY_STRING#","~")>
<cfelse>
<cfset session.PHistName = ListDeleteAt(session.PHistName, I,"~")>
<cfset session.PHistValue = ListDeleteAt(session.PHistValue, I,"~")>
<cfset session.PHistValue = ListPrepend(session.PHistValue, "item.cfm?#CGI.QUERY_STRING#","~")>
<cfset session.PHistName = ListPrepend(session.PHistName, GetProduct.productName,"~")>
</cfif>
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Buy <cfoutput>#GetProduct.productName# #GetProduct.ProductType#</cfoutput> Custom Framed or Box Mounted.</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="keywords" content="<cfoutput>#GetNavName.NavMetaKeyword#</cfoutput>">
<meta name="description" content="Clink on the link to VIEW-BUY your favorite <cfoutput>#GetNavName.NavName#</cfoutput> Posters and Prints. Over 25,000 posters and prints to search from - Get them framed or Unframed">
<link href="urbanposters.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>
<body>
<div align="left">
<!--- header including logo, shopping cart links and search field --->
<cfif session.POS>
<cfinclude template="HeaderPOS.cfm">
<cfelse>
<cfinclude template="HeaderNormal.cfm">
</cfif>
<table width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
<cfif NOT session.POS><!--- left content area --->
<td width="180" align="left" valign="top"><cfinclude template="SearchForm_ap.cfm">
<cfinclude template="navcat_ap.cfm"></td>
</cfif>
<td align="left" valign="top"><table width="600" border="0" cellspacing="4" class="medium">
<form action="cart.cfm" method="post" name="frmItem" onSubmit="MM_validateForm('q','','RisNum');return document.MM_returnValue">
<input name="fa" type="hidden" value="add">
<tr>
<td colspan="2"><h2><cfoutput>#GetProduct.productName# #GetProduct.productType#</cfoutput></h2></td>
</tr>
<tr valign="top">
<td><img src="<cfoutput>#GetProduct.ProductImg2Url#</cfoutput>" alt="<cfoutput>#GetProduct.productname#</cfoutput> posters" hspace="0" vspace="0" border="0" style="border-style:solid; border-color:#CCCCCC; border-width:1px;">


<cfif GetNavRelCat.RecordCount>
<p>&nbsp;</p>
<table width="150" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="22" nowrap><img src="/images/TopLeftWhite.gif" alt="" width="10" height="22" hspace="0" vspace="0" border="0"></td>
<td width="100%" height="2" nowrap bgcolor="#006600" class="boxheader">Related Categories </td>
<td height="22" nowrap><img src="/images/TopRightWhite.gif" alt="" width="10" height="22" hspace="0" vspace="0" border="0"></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="6" bordercolor="#006600" class="boxnavwhite">
<tr>
<td class="medium"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="middle"><cfoutput query="GetNavRelCat"><a href="cat_ap.cfm?nid=#GetNavRelCat.NavID#">#GetNavRelCat.NavName#</a><br>
</cfoutput></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</cfif>

<br>
<a href="javascript:history.back()"><img src="/images/backarrow.gif" alt="" width="40" height="27" border="0" align="middle"></a>&nbsp;<a href="javascript:history.back()">Back to Shopping</a></td>
<td><p>To order this <cfoutput>#GetProduct.productName# #GetProduct.ProductType#</cfoutput> click "Add to Cart". Click "back to shopping" to shop for more posters or art prints. To custom frame your poster or art print, click frame me, then add the custom framed poster or art print to your basket. When ready to checkout, your poster or art print purchase will be safe and secure.</p>
<p>**All poster and art print sizes are approximate.**</p>
<p>&nbsp;</p>
<cfif GetProductMultiSize.RecordCount GT 0>
<cfset I = 0>
<table width="455" border="0" cellpadding="0" cellspacing="4">
<cfoutput query="GetProduct">
<tr valign="top">
<td width="30"><input name="p" type="radio" value="#p#" checked></td>
<td width="181">#GetProduct.PRODUCTNAME#
<p><span class="mediumbold">Size:</span> #GetProduct.productWidth# x #GetProduct.productHeight#</p>
<cfif session.POS>
<p><span class="mediumbold">POS Price:&nbsp;</span>#DollarFormat(GetProduct.productRetailPriceStore)#</p>
<cfelse>
<p>
<cfif GetProduct.productRetailPrice EQ GetProduct.productDiscountPrice>
<span class="mediumbold">Price:&nbsp;</span>#DollarFormat(GetProduct.productRetailPrice)#
<cfelse>
<span class="mediumbold">Was:&nbsp;</span><span class="Discount">#DollarFormat(GetProduct.productRetailPrice)#</span>&nbsp;<span class="mediumbold">Now:&nbsp;</span>#DollarFormat(GetProduct.productDiscountPrice)#
</cfif>
<cfset ItemMsg = "">
<cfif GetProduct.NewProd>
<cfset ItemMsg = "New Item ">
</cfif>
<cfif GetProduct.OnSale>
<cfset ItemMsg = ItemMsg & "On Sale">
</cfif>
<cfif ItemMsg NEQ "">
<br>
<span class="mediumimportant">#ItemMsg#</span>
</cfif>
</p>
</cfif> </td>
<td width="241" nowrap><span class="mediumbold">Code:</span> #GetProduct.PRODUCTCODE#
<p>
<cfif (GetProduct.productWidth LTE application.MaxFrameWidth) AND (GetProduct.productHeight LTE application.MaxFrameHeight)>
<input type="image" onClick="javascript:document.frmItem.p[#I#].checked=true;document.frmItem.fa.value='frame'" src="/images/btnFrameMe.gif" alt="Frame your #GetProduct.PRODUCTNAME# poster here" border="0">
<br>
<!---Framing starts at #DollarFormat(GetProduct.MINFRAMEPRICE)#--->
</cfif>
<br>
<!--- Shipping Message --->
<cfif GetProduct.ProductQOH gt 0>
Shipping within 1 day via 2 Day Priority Mail
<cfelse>
<cfif GetProduct.manufacturerTurnaround NEQ "">
Shipping within #GetProduct.manufacturerTurnaround# via 2 Day Priority Mail
</cfif>
</cfif>
</p></td>
</tr>
</cfoutput> <cfoutput query="GetProductMultiSize">
<cfset I = I + 1>
<tr valign="top">
<td><input name="p" type="radio" value="#GetProductMultiSize.PRODUCTID#"></td>
<td>#GetProductMultiSize.PRODUCTNAME#
<p><span class="mediumbold">Size:</span> #GetProductMultiSize.PRODUCTSIZE#</p>
<cfif session.POS>
<p><span class="mediumbold">POS Price:&nbsp;</span>#DollarFormat(GetProductMultiSize.productRetailPriceStore)#</p>
<cfelse>
<p>
<cfif GetProductMultiSize.productRetailPrice EQ GetProductMultiSize.productDiscountPrice>
<span class="mediumbold">Price:&nbsp;</span>#DollarFormat(GetProductMultiSize.productRetailPrice)#
<cfelse>
<span class="mediumbold">Was:&nbsp;</span><span class="Discount">#DollarFormat(GetProductMultiSize.productRetailPrice)#</span>&nbsp;<span class="mediumbold">Now:&nbsp;</span>#DollarFormat(GetProduct.productDiscountPrice)#
</cfif>
<cfset ItemMsg = "">
<cfif GetProduct.NewProd>
<cfset ItemMsg = "New Item ">
</cfif>
<cfif GetProduct.OnSale>
<cfset ItemMsg = ItemMsg & "On Sale">
</cfif>
<cfif ItemMsg NEQ "">
<br>
<span class="mediumimportant">#ItemMsg#</span>
</cfif>
</p>
</cfif>
<td nowrap><span class="mediumbold">Code:</span> #GetProductMultiSize.PRODUCTCODE#
<p>
<cfif (GetProductMultiSize.productWidth LTE application.MaxFrameWidth) AND (GetProductMultiSize.productHeight LTE application.MaxFrameHeight)>
<input type="image" onClick="javascript:document.frmItem.p[#I#].checked=true;document.frmItem.fa.value='frame'" src="/images/btnFrameMe.gif" alt="Frame your #GetProductMultiSize.PRODUCTNAME# poster here" border="0">
<br>
Framing starts at #DollarFormat(GetProductMultiSize.MINFRAMEPRICE)#
</cfif>
</p></td>
</tr>
</cfoutput>
</table>
<cfelse>
<cfoutput query="GetProduct">
<p><span class="mediumbold">Code:</span> #GetProduct.PRODUCTCODE#</p>
<p><span class="mediumbold">Size:</span> #GetProduct.PRODUCTSIZE#</p>
<cfif session.POS>
<p><span class="mediumbold">POS Price:&nbsp;</span>#DollarFormat(GetProduct.productRetailPriceStore)#</p>
<cfelse>
<p>
<cfif GetProduct.productRetailPrice EQ GetProduct.productDiscountPrice>
<span class="mediumbold">Price:&nbsp;</span>#DollarFormat(GetProduct.productRetailPrice)#
<cfelse>
<span class="mediumbold">Was:&nbsp;</span><span class="Discount">#DollarFormat(GetProduct.productRetailPrice)#</span>&nbsp;<span class="mediumbold">Now:&nbsp;</span>#DollarFormat(GetProduct.productDiscountPrice)#
</cfif>
<cfset ItemMsg = "">
<cfif GetProduct.NewProd>
<cfset ItemMsg = "New Item ">
</cfif>
<cfif GetProduct.OnSale>
<cfset ItemMsg = ItemMsg & "On Sale">
</cfif>
<cfif ItemMsg NEQ "">
<br>
<span class="mediumimportant">#ItemMsg#</span>
</cfif>
</p>
</cfif>
<input name="p" type="hidden" value="#p#">
</cfoutput>
</cfif>
<p><span class="mediumbold">Quantity:</span>
<input type="text" name="q" value="1" size="1" maxlength="2" class="small">
</p>
<p>
<a href="<cfoutput>#GetProduct.ProductLink#</cfoutput>"></a><img src="images/btnAddtoCart.gif" border="0" alt="Click to buy #productname# posters" hspace="2" /></a>
&nbsp;
<cfif GetProductMultiSize.RecordCount IS 0>
<cfif (GetProduct.productWidth LTE application.MaxFrameWidth) AND (GetProduct.productHeight LTE application.MaxFrameHeight)>
<input type="image" onClick="javascript:document.frmItem.fa.value='frame'" src="/images/btnFrameMe.gif" alt="Frame your #getproduct.productname# poster here" border="0">
<br>
Framing starts at <cfoutput>#DollarFormat(GetProduct.MINFRAMEPRICE)#</cfoutput>
</cfif><br>
<!--- Shipping Message --->
<cfif GetProduct.ProductQOH gt 0>
Shipping within 1 day via 2 Day Priority Mail
<cfelse>
<cfif GetProduct.manufacturerTurnaround NEQ "">
Shipping within <cfoutput>#GetProduct.manufacturerTurnaround#</cfoutput> via 2 Day Priority Mail
</cfif>
</cfif>
</cfif>
</p>
<!---<div id=csRecsDiv>If you like this, you may also like these great posters!</div>--->
</td>
</tr>
<tr valign="top">
<td colspan="2"></td>
</tr>
</form>
</table>
 </td>
</tr>
</table>
<!--- bottom navigation gutter --->
<cfinclude template="footer.cfm">
</div>
</body>
</html>
 
Your code says this:

<a href="<cfoutput>#GetProduct.ProductLink#</cfoutput>"></a><img src="images/btnAddtoCart.gif" border="0" alt="Click to buy #productname# posters" hspace="2" /></a>

Try getting rid of that first </a> and see if that does it. If that doesn't work, can you put this just before that block of code?

ProductLink = (<cfoutput>#GetProduct.ProductLink#</cfoutput>)<br>

When you run the page, is there anything in the parentheses?
 
thanks a ton glowball, that worked.. it is always something simple, i swear. if you are ever in baltmore, let me know, i'll buy you a beer. take care.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top