473,395 Members | 1,631 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,395 software developers and data experts.

using a button to perform tasks

29
Hey everyone ...

I have a button on my page:
Expand|Select|Wrap|Line Numbers
  1.      <input name="button" type="button" class="style3" onclick="window.print()" value="Print Coupon" />
  2.  
that uses window.print() to print a coupon. I would like to add a function to the code that updates a field in a database that tracks how many coupons are printed. Is there a way to add this function:
Expand|Select|Wrap|Line Numbers
  1. $CouponNo = $CouponNo + 1;
  2. mysql_query("UPDATE tbl_depts SET CouponNo = $CouponNo WHERE `key` = $spec");
  3.  
to that button?

Thanks for any help

Robert
Dec 7 '07 #1
2 1214
Atli
5,058 Expert 4TB
Hi Robert.

HTML and JavaScript, being server-side monstrosities, can not directly interact with PHP, as that is a server-side language.

You can, however, use tools such as Ajax to make HTTP requests on your server to execute PHP scripts.

For example, if you were to put your PHP code, the one you posted above, in a PHP file, you could use Ajax to request that file from your server, which would effectively increment you coupon count.
Dec 9 '07 #2
rlm51
29
Thanks for your reply. I actually figured it out over the weekend.
In Dreamweaver, you can tag more than one behavior to the "onclick" so I ended up using this code:
Expand|Select|Wrap|Line Numbers
  1.       <input name="button" type="button" class="style3" onclick="window.print() ;MM_goToURL('parent','../DeptSpecials.php');<?PHP $CouponNo = $CouponNo + 1 ?>;return document.MM_returnValue" value="Print Coupon" />
  2.  
Works great ...

Again, thanks for your help.

Hope everyone has a great holiday season.

Robert
Dec 10 '07 #3

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

Similar topics

4
by: @sh | last post by:
Can anyone help out here please, we have a button that when pressed will alert the user, should they cancel no action is taken, however should they confirm, the script will disable the button and...
3
by: Hartmut Schroth | last post by:
Hi, I need a solution for the following problem: In the item template of a datalist control I have already a button control with the commandname set to "select" to perform some specific...
4
by: SAL | last post by:
Hello, I created a WebPage.aspx that has some functions in it, and I created a User Control that has a File Field Control and a Botton control on the .ascx. I added myUserControl.ascx to the...
3
by: =?Utf-8?B?QnJpYW4gTmljaG9sc29u?= | last post by:
I'm building a test web application that, when run, will launch calc.exe on my computer. It seems to work as it appears in Windows Task Manager; however, the process doesn't actually pop up...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.