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

Can I call a function in a onclick event?

chelvan
P: 90
hi
its me again

is it possible to calling a function in < a > onclick event?



thanks in advance
chel-1
Sep 8 '08 #1
Share this Question
Share on Google+
10 Replies


10K+
P: 13,264
You could test it and tell us if it's possible ...
Sep 8 '08 #2

100+
P: 258
Wasn't it easier to test if it'e possible or not instead of waiting for answer from us?
btw, Yes it's possible.
Sep 8 '08 #3

Atli
Expert 5K+
P: 5,058
is it possible to calling a function in < a > onclick event?
You can execute any client-side script in an event like that.
Unless you are trying to execute a PHP function?

I would have to agree with the others tho... it should only take you like a minute to test that yourself.

Btw, I changed the thread title. Please try to make your titles descriptive. Simply stating something like "onclick" isn't really helpful.

Check out the Posting Guidelines to see what makes a good thread title.

MODERATOR
Sep 8 '08 #4

Markus
Expert 5K+
P: 6,050
As Atli said: you can run client side functions easily with an onclick event. However, you posted this in the PHP forum, so I'm a little sketchy as to your question. PHP or Javascript?
Sep 9 '08 #5

chelvan
P: 90
As Atli said: you can run client side functions easily with an onclick event. However, you posted this in the PHP forum, so I'm a little sketchy as to your question. PHP or Javascript?
yes sir
my question is on php.

chel-1
Sep 10 '08 #6

Atli
Expert 5K+
P: 5,058
You can't call server-side code from within client-side code.
The only way to do that would be to either completely reload the page or use AJAX.
Sep 10 '08 #7

100+
P: 258
Hi
The other option is to have a hidden IFRAME and refresh it with a java script.
It wont be hard
Sep 10 '08 #8

100+
P: 258
Here's how you can do it:

Expand|Select|Wrap|Line Numbers
  1. <head>
  2. <script type="text/javascript" >
  3.     function refresh()
  4.     {
  5.         frames['myframe'].location.reload();
  6.     }
  7. </script>
  8.  
  9. </head>
  10.  
  11. <body>
  12. <a onclick="refresh();">Click me</a>
  13. <iframe name="myframe" id="myframe" frameborder="0" src="funcContainer.php" width="50" height="50" style="display:none"></iframe><br />
  14. </body>
  15.  
  16.  
  17.  
When you click on the link the IFRAME refreshes the page which is funcContainer.php

But if you use this code you wont see the ifram. If you want to make sure this code works delete (style="display:none") from the IFRAME tag.

Good luck
Sep 10 '08 #9

chelvan
P: 90
thanks forum.

i try & do it with ur guides.


thanks a lot
chel-1
Sep 11 '08 #10

P: n/a
This worked really good!!
Oct 23 '10 #11

Post your reply

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