473,789 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using a button to perform tasks

29 New Member
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 1225
Atli
5,058 Recognized Expert Expert
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 New Member
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
2856
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 then submit the form... Could someone correct this lump of code for us pleaseeeeeeee ;o) <input name="Submit" type="button" class="EmployerPostJobForm" value=" Verify Job " id="mFormSubmit" onClick="if(confirm('You are about to verify this...
3
2529
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 database action. I additionally want to update an integer value in the underlying data source by simply clicking an a check box or an imagebutton WITHOUT USING THE EDIT/UPDATE COMMANDNAME property of the
4
1393
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 WebPage.aspx, but it can not access the WebPage.aspx functions. If I add a button to the WebPage.aspx, I can access those functions no problem. Is not adding a User Control the samething? If not, what must I do in myUserControl.ascx file so I...
3
3575
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 because it runs as ASPNET rather than the user I want. When having to run ASP.NET as another user (e.g. when doing AD queries), I was able to use IIS Windows Authentication and impersonation. These are still enabled, but they don't seem to be helping....
0
9656
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9499
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10124
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5540
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4078
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2898
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.