473,546 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

onClick

Ken
Does php work with onClick in an html input statement?

<HTML>
<input type="button" name="add_pictu re" value="Add another picture"
onClick="<?php picture_count() ; ?>">

I want to call the function picture_count() when button labeled "Add another
picture" is clicked in HTML

I do not want to use submit in place of button since I do not want to submit
the form at this time.

With the above statement, I receive an error expected ";" and the function
is not called.

Thanks!
Jul 17 '05 #1
2 40104
Ken wrote:
Does php work with onClick in an html input statement?

<HTML>
<input type="button" name="add_pictu re" value="Add another picture"
onClick="<?php picture_count() ; ?>">

I want to call the function picture_count() when button labeled "Add another
picture" is clicked in HTML

I do not want to use submit in place of button since I do not want to submit
the form at this time.

With the above statement, I receive an error expected ";" and the function
is not called.

Thanks!


The function will not be called because:

A) PHP is serverside whereas the onclick event you are trying to catch
is client side.

B) the onclick attribute is (to my knowledge) expected to refer to a
javascript function/statement.

From what you've posted I can't tell exactly what is supposed to be
done when the user clicks the button (ie. what your function does) but
maybe you can consider using some javascript to reload the page and
update whatever your function was updating.

-Steve
Jul 17 '05 #2
Ken wrote:
Does php work with onClick in an html input statement?

<HTML>
<input type="button" name="add_pictu re" value="Add another picture"
onClick="<?php picture_count() ; ?>">

I want to call the function picture_count() when button labeled "Add another
picture" is clicked in HTML

I do not want to use submit in place of button since I do not want to submit
the form at this time.

With the above statement, I receive an error expected ";" and the function
is not called.

Thanks!

You are mixing two different technologies together... PHP is server side
- The onClick event is client side... This means that your PHP code is
parsed/run BEFORE it gets to the user/client side.

If PHP is correctly configured on your server, then view the page where
you have the above code - My bet is that in the 'onClick' event, you
will NOT see <?php picture_count() ; ?> but instead see the result of
picture_count() - And unless you manage to store the value/result of
picture_count somewhere on your server, then I'd guess that the value
will always be the same, no matter how many uploads you did.

Chances are, someone in comp.lang.javas cript will (at least in part)
help you towards a solution...

laters
randelld
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3671
by: Shock | last post by:
Hello everyone, I am having a problem with the program below. I have isolated the problem to the onclick event that is located throughout arrQuestions. The onclick event refers to a function and passes it two parameters. For the life of me I cannot figure out what the error is, but one occurs everytime I click a &%*$&# radio button. ...
17
61408
by: Mike Gratee | last post by:
Is it possible to use JavaScript to cause the browser to click a link on a page and have the browser act exactly like the user had clicked on the link directly? In other words, I need to programmatically issue a JavaScript statement which causes the browser to act just like the user clicked on a link in my page. And if that link has an...
2
9149
by: Kevin Lyons | last post by:
Hello, Can anyone assist me with what I am trying to do with the following code (six different scenarios to try to make the functionality work correctly)? I want to always (and ONLY) display in the status bar 'Symantec Corporation' whenever anyone mouses over (onMouseOver) my image or link OR when one clicks while holding the left mouse...
3
3243
by: Jamie Jackson | last post by:
I'm rewriting all links' onclick events, but I'm having a problem. The onclick event that I'm inserting works correctly in Opera, but not in FF or IE. I'm retroactively adding the statement "return promptBeforeOpening();" FF and IE rewrite it as I would expect them to, but it turns out that that doesn't work (no disclaimer pops up, and...
2
18551
by: RobG | last post by:
I am trying to dynamically add an onclick to an element, however I just can't get the syntax right. consider the following function: function doClick (evt,x) { // do things with evt and x } Which is called statically by: <button onclick="doClick(event,this);">Click me</button>
2
3278
by: Sedef | last post by:
Hi, i'm trying to create a custom Button user control which will be derived from System.Web.UI.WebControls.Button. the normal server side Button class creates some client side javascript code for its onclick event. it's something like: <input type="submit" name="Button1" value="Button" onclick="if (typeof(Page_ClientValidate) == 'function')...
6
7160
by: Nx | last post by:
i've got it all working nicely in firefox, but whenever i test it in IE none of the onclick events are triggered. i'm using an xsl to transform an rss feed into a photogallery. when i try to use setAttribute FF and safari work, but IE stops working when i used addEventListener and attachEvent safari stops working and when i tried...
7
2785
by: extremerep | last post by:
My task is to change the value of a button and then make it functional with the onClick handler. Changing the value to "Play Again" works, but making the onClick work accordingly does not. The following is a snippet of the script. What is keeping it from working? function displaycards1(){ document.form1.reveal1.value="Play Again";...
2
1875
vivekgs2007
by: vivekgs2007 | last post by:
Hi i am doing a application that add the rate of the staff evaluation please go through o=it and need help <?php include("../db.php"); session_start(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" >
0
7507
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...
0
7435
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...
0
7698
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7947
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7794
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...
0
3472
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1922
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
1
1046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
747
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...

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.