How to call a php-function by using onclick-event?

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Thoaren

Thoaren

10/04/2006 13:21:00
Quote Anchor link
Hi guys,

How can I call a php-function by using the onclick-event?

Thanx for help.

Thomas
 
PHP hulp

PHP hulp

25/12/2024 14:45:57
 
Eris -

Eris -

10/04/2006 13:23:00
Quote Anchor link
You can't PHP is serverside and javascript (onclick) is client side.
 

10/04/2006 13:34:00
Quote Anchor link
While using AJAX techniques you can request output of a php script
Gewijzigd op 01/01/1970 01:00:00 door
 
Thoaren

Thoaren

10/04/2006 13:39:00
Quote Anchor link
Can I do it by using a javascript?
Example:

<a href="index.php" onclick="document.write('functions.php')">TEST</a>

Thanx for help,

Thoaren
 

10/04/2006 13:57:00
Quote Anchor link
AJAX is javascript. Look for a tutorial.

Perhaps you don't need AJAX (depends on your prblem) Probably you can do it by invoking (submit0 another page?
 
Steff   an

Steff an

10/04/2006 15:01:00
Quote Anchor link
When you tell us what you want to make, maybe we can help you to solve the problem or we give you some ideas.
I mean: why you need a client-side event for PHP?
 
PHP erik

PHP erik

10/04/2006 15:17:00
Quote Anchor link
Thoaren, "serverside" means that calling a PHP function, or script, would always require a reload of the page. AJAX is a technique to load a file (just like reloading), but then within the current page. However, in most cases there's a better workaround than AJAX. So in interest of performence, and in interest of good code, please tell us your exact problem.

Welcome to PHPhulp by the way.
Gewijzigd op 01/01/1970 01:00:00 door PHP erik
 
Thoaren

Thoaren

10/04/2006 15:26:00
Quote Anchor link
I have a header.php with menu in it.
When clicked on one of the menu-items, header.php and the corresponding page from the menu is been included in index.php.
This a will not change.

So this is the situation description:

*index.php:
-includes header.php
-includes corresponding page from de menu in header.php
-includes footer.php

*header.php with menu

*corresponding pages, let's say: page01.php and page02.php

This I will not change.

Now I want to change the backgroundimage of a cell in the menu when the corresponding page, let's say page02.php is loaded in the index.php. The backgroundimage of the other menu-items must be change to standard then. I want to do the same when page01.php is loaded in index.php. Also the backgroundimage of the other menu-items must be change to standard then.


Thanx for help.

Thoaren
 
PHP erik

PHP erik

10/04/2006 19:09:00
Quote Anchor link
Well, you can do that by using only Javascript.


<script>
function BackToNormal() {
document.getElementById('name1').style.background='url(normal.gif) no-repeat;';
document.getElementById('name2').style.background='url(normal.gif) no-repeat;';
document.getElementById('name3').style.background='url(normal.gif) no-repeat;';
}

function LoadNewImage(element, url) {
element.style.background='url(' +url+ ') no-repeat;';
}
</script>

<something id="name1" onClick="BackToNormal(); LoadNewImage(this, 'something.gif');">

<something id="name2" onClick="BackToNormal(); LoadNewImage(this, 'somethingelse.gif');">



Just be smart with the names and Javascript functions. This was just an example.
 
Mitch X

Mitch X

10/04/2006 19:12:00
Quote Anchor link
Spreken wij geen Nederlands op PHPhulp.nl?
Of zijn we internationaal gegaan en heeft niemand me wat verteld?
 
Han eev

Han eev

10/04/2006 19:21:00
Quote Anchor link
Hij begon in het engels ;)
 
Steff   an

Steff an

10/04/2006 19:50:00
Quote Anchor link
Hij spreekt ook nederlands, zie wat in een pm stond:

Quote:
Hi Erik,

You posted on:http://www.phphulp.nl/forum/showtopic.php?cat=7&id=16372&page=

I explaned my situation now.
Can you please help me out with this?

Thanx,

Thoaren

p.s.: Ik spreek ook nederlands.

Alleen sinds wanneer heet ik Erik??
 
Mitch X

Mitch X

10/04/2006 19:54:00
Quote Anchor link
Dan kan ie dat mooi doen dan :P
 
Thoaren

Thoaren

10/04/2006 20:03:00
Quote Anchor link
Sorry,

Het is de macht der gewoonte.

Kan iemand mij helpen met deze topic?

Groeten,

Thoaren
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.