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

onClick

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

<HTML>
<input type="button" name="add_picture" 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 40097
Ken wrote:
Does php work with onClick in an html input statement?

<HTML>
<input type="button" name="add_picture" 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_picture" 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.javascript 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
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...
17
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...
2
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...
3
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...
2
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 } ...
2
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...
6
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...
7
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...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
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
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...
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.