473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Saving variables on a click

I have a menu made up of images where users can click an image to load the
next page. I want each image to send a unique id number to the page the
user loads. Based on this id number, the page that will be loaded will
display something different.

Since I'm not using a form to post data, I decided to save the id number as
a session variable. The loaded page will read the variable when determining
what to load. The problem I'm encountering is where to put the code to get
the first page to save the id number (I know how to save and retrieve
session variables, so that's not an issue).

I've tried putting the php script inside the onclick attribute of the link,
but that didn't work. Does anyone know how I can do this, or know a better
way? Thanks.

--
John Victor
Jul 17 '05 #1
3 2002
I noticed that Message-ID:
<tb*****************@newssvr21.news.prodigy.com> from John Victor
contained the following:
I've tried putting the php script inside the onclick attribute of the link,
but that didn't work. Does anyone know how I can do this, or know a better
way? Thanks.


What's wrong with passing the variable in the URL?

<a href="display_page.php?id=1"><img src="img1.jpg"></a>

On the receiving page, the variable will be $_GET['id']

The best way to proceed would be to then get the information from a
database, based on that variable.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
in post: <news:tb*****************@newssvr21.news.prodigy.c om>
John Victor <wi******@pacbell.net> said:
I have a menu made up of images where users can click an image to load the
next page. I want each image to send a unique id number to the page the
user loads. Based on this id number, the page that will be loaded will
display something different.


http://butterflies.usenetshit.info/

What is the accepted way to share a message across multiple newsgroups?
http://smjg.port5.com/faqs/usenet/xpost.html

--
i h e a r v o i c e s

Jul 17 '05 #3
"John Victor" <wi******@pacbell.net> wrote in message news:<tb*****************@newssvr21.news.prodigy.c om>...
I've tried putting the php script inside the onclick attribute of the link,
but that didn't work. Does anyone know how I can do this, or know a better
way? Thanks.


These are two different technologies, javascript and PHP cannot
interact in this way, PHP is entirely server-side so knows very little
of what the user is doing.

try altering the link that each image uses and placing a parameter on
the end:

<A href="phppage.php?pictureid=111"><img src="img111.jpg"></a>

then in the PHP on the page you go to, you can retrieve this with
$_GET['pictureid']
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: William Morris | last post by:
We have a number of clients using a web application. Each client sees a slightly different version of, say, a contact input page. As a simple example, Client #1 sees demographics, plus religious...
0
by: Stu | last post by:
Hi, I want to be able to come up with some way of navigating around a system that allows me to save certain screen info (Say combo box setting) so that when returning to the screen from a link...
4
by: SilentThunderer | last post by:
Hey folks, Let me start out by letting you know what I'm working with. I'm building an application in VB 2005 that is basically a userform that employees can use to "Clock in". The form...
9
by: Wingot | last post by:
Hey, I am using Visual Studio 2008 Beta 2 for some application development in C#, but I presume that the following question applies equally well to any environment.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.