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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CF_TwoSelectsRelated Breaks Javascript (Inserts Hard Returns in JS)

Status
Not open for further replies.

Khuxley

Programmer
Apr 8, 2003
3
CA
Hi all,

I am trying to use the custom tag CF_TwoSelectsRelated and I'm running into a strange problem. For some reason Cold Fusion is inserting hard returns into the Javascript that CF_TwoSelectsRelated generates after it's called by my CF page. As a result, when I select an item from select menu 1, it is not updating the options list in select menu 2.

If I view source on the generated page, remove these hard returns, save as html and view in a browser, select menu 2 updates with new options each time I select a new item in select box 1. However, this does little to help me handle live database transactions.

My page that calls the CF_TwoSelectsRelated custom tag:
-----------------------------------------
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>
<cfquery datasource=&quot;#DataSource#&quot; name=&quot;qrysectcat&quot;>
SELECT selectID, section, sectcode, catcode, category
FROM sectioncat_test;
</cfquery>
<body>
<FORM ACTION=&quot;TestTwoSelectsRelatedGo.cfm&quot; METHOD=&quot;POST&quot; onSubmit=&quot;return
require_CategoryAndSelection()&quot; NAME=&quot;myform&quot;>
<CF_TwoSelectsRelated QUERY=&quot;qrysectcat&quot; NAME1=&quot;sect&quot; NAME2=&quot;cat&quot;
DISPLAY1=&quot;section&quot; DISPLAY2=&quot;category&quot; VALUE1=&quot;sectcode&quot; VALUE2=&quot;
catcode&quot; SIZE1=&quot;Auto&quot; SIZE2=&quot;Auto&quot; AUTOSELECTFIRST=&quot;No&quot; FORMNAME=&quot;myform&quot;>
<INPUT TYPE=&quot;Submit&quot;>
</FORM>
</body>
</html>
-----------------------------------------
My page throws the following javascript error when I browse within Homesite:

&quot;Unterminated string content&quot;

When I view source on the code that CF generates, all of my data is being pulled from the database table but hard returns are being inserted into the &quot;if&quot; statements after each array element before the closing double quotes:
-----------------------------------------
if (menuNum == 0) {
NewOpt = new Array;
NewVal = new Array;
NewOpt[0] = new Option(&quot;cat1art
&quot;); NewOpt[0].value = 'artone'; NewOpt[1] = new Option(&quot;cat2art
&quot;); NewOpt[1].value = 'arttwo'; NewOpt[2] = new Option(&quot;cat3art
&quot;); NewOpt[2].value = 'artthree'; NewOpt[3] = new Option(&quot;cat4art
&quot;); NewOpt[3].value = 'artfour'; NewOpt[4] = new Option(&quot;cat5art
&quot;); NewOpt[4].value = 'artfive'; NewOpt[5] = new Option(&quot;cat6art
&quot;); NewOpt[5].value = 'artsix'; NewOpt[6] = new Option(&quot;cat7art
&quot;); NewOpt[6].value = 'artseven'; NewOpt[7] = new Option(&quot;cat8art
&quot;); NewOpt[7].value = 'arteight'; NewOpt[8] = new Option(&quot;cat9art
&quot;); NewOpt[8].value = 'artnine'; NewOpt[9] = new Option(&quot;cat10art
&quot;); NewOpt[9].value = 'artten';
}
etc...
-----------------------------------------
System:
Windows XP Pro running Cold Fusion Server 6.1 on localhost.
mySQL database on localhost
Browsers: IE 5.5 & Netscape 7
-----------------------------------------
I removed all hard returns in the TwoSelectsRelated custom tag. No effect. I've activated whitespace management in the Cold Fusion administrator. No effect. (Now deactivated). Searched the Macromeida forums as well. No good. I'm stumped.

I can't figure out where these hard returns are coming. Anyone have experience with a similar problem? Thank you in advance for any help on this.

Puzzled,

Ken


 
I've successfully used this tag. I have no idea what would cause something like this. If you wish, I can email you the version that I'm using just to see if something is quirky with your version. Let me know.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top