Jump to content

OnClick set Var Function..


BaconBeast321

Recommended Posts

Hi there, I want to be able to set a OnClick for a picture that runs a function that makes a variable = 1..
How do I go about doing this? I know how to do it in javascript, but this needs to be PHP.

Essentially it is for the manager of the site, he can click on a button which adds like a linebreak '<BR>' or something
into the news report he is making...

Have tried looking around for solutions but cant find any, help much appreciated!
Link to comment
Share on other sites

PHP can't do anything with onCLick unless there is a javascript function that sets the value of a form input that is then submitted to the server.

e.g.
[code]
<a href="javascript:document.forms[0].some_click_flag.value=1;">your picture</a>
[/code]
then only when forms[0] is submitted will the server get some_click_flag and know that the picture was clicked.

Perhaps you want the user to click and send stuff to the server without having to reload your page.  To do that, you can set upa hidden frame that holds forms with hidden inputs that are sumitted when the user clicks photos in the visible frame.
Link to comment
Share on other sites

your form can look like this-
[code]
<form enctype="multipart/form-data" method="post">
<input type="hidden" name="click" value=""></form>
[/code]

and then in the HTML of your page, the image will look like this:
[code]
<img src="pictobeclicked.jpg" onClick="document.forms[0].click.value=1;document.forms[0].submit();">
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.