Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 08-16-2006, 08:14 AM   #1 (permalink)
markster
Code Monkey
 
markster's Avatar
 
Join Date: Jun 2006
Posts: 65
markster is on a distinguished road
Question Problem with functions

How can I use a button to trigger a PHP function? I thought it might be a code like:

HTML Code:
<input type="button" value="Click Me!!!" onClick="I DUNNO">
Please help!!!
markster is offline   Reply With Quote
Old 08-16-2006, 08:47 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,487
sde is on a distinguished road
You can't. (unless you use AJAX, which I would not recommend before you understand how PHP works)

PHP only runs server-side. It is used to print text to the browser.

HTML/Javascript runs on the client (browser). By the time the HTML is drawn, PHP is done running.

You would have to request a new PHP page (submit an html form to a PHP page) to access PHP functions.
__________________
Mike
sde is offline   Reply With Quote
Old 08-16-2006, 08:50 AM   #3 (permalink)
markster
Code Monkey
 
markster's Avatar
 
Join Date: Jun 2006
Posts: 65
markster is on a distinguished road
Awww, thats not good!
markster is offline   Reply With Quote
Old 08-16-2006, 09:00 AM   #4 (permalink)
markster
Code Monkey
 
markster's Avatar
 
Join Date: Jun 2006
Posts: 65
markster is on a distinguished road
Second thoughts, is there anyway to use PHP to trigger a javascript function?
markster is offline   Reply With Quote
Old 08-16-2006, 09:34 AM   #5 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,709
redhead is on a distinguished road
PHP Code:
<?php 
echo "<script language=\"Javascript\">my_function();</script>";
?>
Else I dont see how... remember php is server-side, javascript is client side, so unless you tie them together through Ajax, theres not much interaction between them.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 08-16-2006, 10:13 AM   #6 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,487
sde is on a distinguished road
surely there is a way to do what you want to do with either javascript or php. what exactly are you trying to do with the button click?
__________________
Mike
sde is offline   Reply With Quote
Old 08-16-2006, 12:08 PM   #7 (permalink)
markster
Code Monkey
 
markster's Avatar
 
Join Date: Jun 2006
Posts: 65
markster is on a distinguished road
dont worry, ive managed to recreate the javascript in PHP, so its all in php now!
markster is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inheritance and functions... Aniviel833 Standard C, C++ 20 09-18-2005 01:18 PM
parse error problem in game.. can't seem to find problem solution. slashdot Standard C, C++ 5 08-03-2005 08:15 PM
Urgently need help, Functions and leap year problem cleverest Standard C, C++ 17 04-01-2005 12:29 PM
Hashing problem jodders Standard C, C++ 1 02-09-2005 01:51 PM
Problem Assignment (Urgent help req.) Boltress Standard C, C++ 0 01-12-2005 07:59 AM


All times are GMT -8. The time now is 11:21 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting