By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,639 Members | 2,276 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,639 IT Pros & Developers. It's quick & easy.

using a button to perform tasks

P: 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
Share this Question
Share on Google+
2 Replies


Atli
Expert 5K+
P: 5,058
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

P: 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

Post your reply

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