Action on Image Clicked
Moderator: General Moderators
Action on Image Clicked
I want to change the contents of layers when users click on icons. For example, click on the News icon and the main panel displays news from the database.
How can you know when an icon has been clicked on? (the icon is a roll-over image) I don't want to link to another page.
Thanks in advance.
How can you know when an icon has been clicked on? (the icon is a roll-over image) I don't want to link to another page.
Thanks in advance.
Code: Select all
onClick='yourJavaScriptFunction();'- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
I don't use a CMS, but I have used Drupal before, and if any of them are similar, they DO go to a different page. The pages may look extremely similar, or be the same physical file with POST/GET requests, but it's still a different page.
Server-side code delivers content. Client-side code responds to events.
Server-side code delivers content. Client-side code responds to events.
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Code: Select all
if(isset($_GET['a']) && $_GET['a'] == 'login')
{
echo '<form id="login" method="post"><input type="text" /><input type="password" /><input type="submit" /></form>';
}
else
{
echo '<p>Would you like to <a href="?a=login">login to your account</a>?</p>';
}-
timgolding
- Forum Newbie
- Posts: 14
- Joined: Tue Jul 24, 2007 9:02 am
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
"Changing" a page is client-side and is handled by the client's browser and client-side code. Serving a different page is handled server-side and is controlled by the server. I'm fairly sure that the CMS being referred to is not ruled by JavaScript and does not "change" pages, but serves a different one.timgolding wrote:php will not directly handle the clicks but instead can be used to echo some Java script that will handle the clicks.
I think everyone is confused because 'goto a different page' and 'change the current page' are the same thing?
Can you differentiate for us?
A page that looks just like another is still a different page. POST requests and GET requests are a part of a page, so even if it is the same physical file, it is still a different page. The most obvious difference is that when you serve a new page, pressing the back button in your browser will take you back to the previous one, but when you "change" a page with JavaScript, the back button would send you farther than you may expect.
It works, but flickers when the page reloads. Here is what I did:
// For the button
a href="index.php?Content=consulting"...
This reloads the same page:
<?php
if(isset($_GET['Content']) && $_GET['Content'] == 'consulting')
{
echo 'Test worked!';
}
else
{
echo 'Didnt work';
}
When the "Consulting" button is clicked the page flickers and the success message is shown.
// For the button
a href="index.php?Content=consulting"...
This reloads the same page:
<?php
if(isset($_GET['Content']) && $_GET['Content'] == 'consulting')
{
echo 'Test worked!';
}
else
{
echo 'Didnt work';
}
When the "Consulting" button is clicked the page flickers and the success message is shown.