Hello, I'm not here to beg for code or anything i just need some help as to something I'm doing.
I'm fairly good with php and I have been trying to do something with no luck.
I want to make 3 links and 3 hidden images. When you click on 1 link an image appears, when you click on the other one another image appears and takes the place of the first one.
I can easily do that with either css and javascript but I was searching for a way to be able to send the information to php.
For example if the person is seeing image1 then clicks submit i want php to be able to get the url or some way to say that the person chose image1 , same if he chose image 2 and image 3.
I know that php is server side and not client side but I'm trying to find a way to use ajax and all but I'm not really good at it.
I would really appreciate some place to start, like i said at the beginning not here to get someone to do my job I just need a place to start because up to this point I have got nothing.
Thank you, appreciate any help.
Php and images
Moderator: General Moderators
Re: Php and images
Hi , try this ajax ..
[text]var xmlhttp;
function GetXmlHttpRequest() {
xmlhttp = false;
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e) {
xmlhttp = new XMLHttpRequest();
}
}
}
function load_img(iType) {
GetXmlHttpRequest();
xmlhttpt.open("GET","page.php?type="+iType,true) ;
xmlhttp.send(null);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
document.getElementById('someid').innerHtml = xmlhttp.responseText;
}
}
}
[/text]
and for your php page you can make switch or if ... etc .
but for easy way make it with js or jquery
[text]var xmlhttp;
function GetXmlHttpRequest() {
xmlhttp = false;
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e) {
xmlhttp = new XMLHttpRequest();
}
}
}
function load_img(iType) {
GetXmlHttpRequest();
xmlhttpt.open("GET","page.php?type="+iType,true) ;
xmlhttp.send(null);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
document.getElementById('someid').innerHtml = xmlhttp.responseText;
}
}
}
[/text]
and for your php page you can make switch or if ... etc .
but for easy way make it with js or jquery
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Php and images
To retrieve any data from the url in php use $_GET;
To access the value of id you would use $_GET['id'] and it will contain a value of 5
Code: Select all
<form action="page.php?id=5" method="post" />
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering