473,406 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to call JavaScript function?

219 100+
I want to call a javascript function if my cfif logic is True. How do I call the javascript function? I just want to have a popup alert saying that the choice already exists, and then send the user back to the main page.

Expand|Select|Wrap|Line Numbers
  1. <cfif isDefined("Form.Add")>
  2. <cfquery name="validateName" datasource="Security_Access" dbtype="ODBC">
  3.         select sysID from tblSystem
  4.         where name='#Form.name#'
  5.     </cfquery>
  6.     <cfif "validateName.RecordCount" eq 1>
  7.         <cfoutput>sysExists(#Form.name#)</cfoutput>
  8.         <cflocation URL="system.cfm">
  9.     <cfelse>
  10.         <cfquery name="insertSystem" datasource="Security_Access" dbtype="ODBC">
  11.             insert into tblSystem (name,description,updDateTime)
  12.             values ('#name#','#description#','#DateTime#')
  13.         </cfquery>
  14.     </cfif>
  15. </cfif>
  16.  
Oct 1 '07 #1
3 26102
acoder
16,027 Expert Mod 8TB
Just add the code within script tags as you would in an HTML page:

[HTML]<script type="text/javascript">
// JS code ..
</script>[/HTML]
Oct 1 '07 #2
JavaScript will be executed at the client side after the page is parsed by ColdFusion at the server side such that a code such as below is perfectly valid:

Expand|Select|Wrap|Line Numbers
  1. <script>
  2. alert('#variables.intInteger#');
  3. </script>
  4.  
When JavaScript reaches this line of code, the CF part would've already been replaced by the value it is assigned to.

In your case you could simply write the JS piece along with the CF code.
Nov 9 '10 #3
In the cfif logic where u want to get the alert and needs to re-direct, code like this

Expand|Select|Wrap|Line Numbers
  1. <cfif ... 
  2.  
  3. <script type="text/javascript">
  4. alert("choice already exists");
  5. </script>
  6.  
  7. <cflocation URL="system.cfm">
  8.  
  9. <cfelse>
  10.  
  11. <!------codes------>
  12.  
  13. </cfif>
May 5 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: chirs | last post by:
I am trying to understand a piece of code. In a javascrpit file, there is a function: function ItemStyle(){ var names=; addProps(this,arguments,names,true); }; In the html file, it calls...
5
by: Sue | last post by:
After finishing up my first quarter JavaScript on 12/12/03, I decided to improve character checking on my project. In my project I only had to do very basic validation. Therefore, I only had one...
1
by: cheezebeetle | last post by:
ok, so I am having problems passing in an ASPX function into the Javascript in the codebehind page. I am simply using a confirm call which when they press "OK" they call this ASPX function, when...
3
by: JoeK | last post by:
Hey all, I am automating a web page from Visual Foxpro. I can control all the textboxes, radio buttons, and command buttons using syntax such as: ...
39
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. ...
18
by: Chris Ianson | last post by:
Hi geniuses (or is that genii, or genies) The challenge is as above really. I have a page with an iframe in it, and need to call a JS function in the *parent* page, *from* inside the iframe. ...
3
by: KaNos | last post by:
Hi, "robot script pages" are html+javascript pages, can be played in aspx player. So in this tech, robot call aspx player's function (an interface is sheared) and wait a result synchronously with...
3
by: Angus | last post by:
I have a web page with a toolbar containing a Save button. The Save button can change contextually to be a Search button in some cases. Hence the button name searchsavechanges. The snippet of...
10
by: evicailieva | last post by:
A have a php scrip where I call a JavaScript function. I don't know why, but it doesn't work. At the beginning, when I was writing the script it was working but now it's not. I don't know wхat to do....
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.