Note that there are some explanatory texts on larger screens.

plurals
  1. POCan I have a coldfusion tag inside a Javascript tag?
    primarykey
    data
    text
    <p>I'm trying to print out info from a database using JQuery and coldfusion to display info of a student and their parking permit info, and other things related to the car they have on campus. When I try to load the webpage, I get an error saying that on line 84: </p> <p><code>&lt;cfquery name="q_sample" datasource="cars_live"&gt;</code></p> <p>There is an unexpected token: "&lt;". I'm guessing this is because it's already under the javascript tag. Is there any way to make JS and coldfusion work together, because in order to read what I want from the database, I need <code>&lt;cfquery name="q_sample" datasource="cars_live"&gt;</code> and <code>$(this).text()</code>.</p> <p>Here is the code for the student info page. #plates is just the name of the list with the item that the user clicked that brought them to this page.</p> <pre><code>&lt;div data-role="page" id = 'Student' data-add-back-btn="true"&gt; &lt;div data-role="header"&gt; &lt;h1&gt;Student Info Page&lt;/h1&gt; &lt;/div&gt;&lt;!-- /header --&gt; &lt;div data-role="content"&gt; &lt;script type="text/javascript"&gt; $("#plates li").click(function() { &lt;cfquery name="q_sample" datasource="cars_live"&gt; SELECT FIRST 10 * FROM veh_rec WHERE LICENSE=$(this).text() &lt;/cfquery&gt; &lt;cfoutput query="q_sample"&gt; &lt;p&gt;License Plate Number: #license#, &lt;br&gt; Permit ID Number: #decal#, Student ID Number: #ID#&lt;/p&gt; &lt;/cfoutput&gt; }); &lt;/script&gt; &lt;/div&gt; &lt;!-- /content --&gt; &lt;/div&gt; &lt;!--/Student --&gt; </code></pre> <p>If you need any additional information please let me know!</p> <p><strong>UPDATE</strong> After taking Steve's advice, this is my new code.</p> <p>joey.cfm</p> <pre><code>&lt;cfparam name="License" default=""&gt; &lt;cfquery name="q_sample" datasource="cars_live"&gt; SELECT * FROM veh_rec WHERE LICENSE=&lt;cfqueryparam cfsqltype="cf_sql_varchar" value="#License#"&gt; &lt;/cfquery&gt; &lt;cfoutput query="q_sample"&gt; &lt;p&gt;License Plate Number: #license# &lt;br&gt; Permit ID Number: #decal#&lt;br&gt; Student ID Number: #ID#&lt;/p&gt; &lt;/cfoutput&gt; </code></pre> <p>Part of html file</p> <pre><code>&lt;div data-role="page" id = 'Student' data-add-back-btn="true"&gt; &lt;div data-role="header"&gt; &lt;h1&gt;Student Info Page&lt;/h1&gt; &lt;/div&gt;&lt;!-- /header --&gt; &lt;div data-role="content"&gt; &lt;script type="text/javascript"&gt; $("#plates li").click(function() { var strLicense=$(this).text(); $.get("joey.cfm", { license: strLicense}) .done(function(data) { alert("Data Loaded: " + data); $("#myResults").html(data); }); }); &lt;/script&gt; &lt;div id="myResults"&gt;&lt;/div&gt; </code></pre> <p>only problem now is that I cant get a return value unless I hard code in the license plate in the "value" area.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload