473,756 Members | 2,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

image swapping in php

I'm beginning to undertake php for the fun of it.

Working on a problem I hope can be solved in php.
Basically what I have is this:

<body>

<img name="main" src="image1.jpg ">
<a href="#"
onMouseOver="do cument.main.src ='image2.jpg'"
onMouseOut="doc ument.main.src= 'image1.jpg'">o ne</a>

</body>

Ok I know, shoot me. I know "name" is not a valid attribute but it works.
If I use "ID" it does not work.

How would I go about converting this same effect to PHP?

Jul 17 '05 #1
5 2953
"Richard" <anom@anom> schrieb im Newsbeitrag
news:bm******** @enews2.newsguy .com...
I'm beginning to undertake php for the fun of it.

Working on a problem I hope can be solved in php.
Basically what I have is this:

<body>

<img name="main" src="image1.jpg ">
<a href="#"
onMouseOver="do cument.main.src ='image2.jpg'"
onMouseOut="doc ument.main.src= 'image1.jpg'">o ne</a>

</body>

Ok I know, shoot me. I know "name" is not a valid attribute but it works.
If I use "ID" it does not work.

How would I go about converting this same effect to PHP?


You can't do that. A mouseover event is processed at the client side (by the
browser); PHP runs at the server side.

If you understand that difference you will have much fun by making
Javascript (client side) and PHP (server side) work hand in hand.

--
Markus
Jul 17 '05 #2
On Thu, 9 Oct 2003 20:04:58 -0500, "Richard" <anom@anom> wrote:
I'm beginning to undertake php for the fun of it.

Working on a problem I hope can be solved in php.
Basically what I have is this:

<body>

<img name="main" src="image1.jpg ">
<a href="#"
onMouseOver="do cument.main.src ='image2.jpg'"
onMouseOut="doc ument.main.src= 'image1.jpg'">o ne</a>

</body>

Ok I know, shoot me. I know "name" is not a valid attribute
No firearms required; it's perfectly valid. <img> does have a name attribute.

http://www.w3.org/TR/html4/struct/objects.html#h-13.2
How would I go about converting this same effect to PHP?


Once the HTML (or whatever you've output with PHP) has been sent to the
browser, PHP has no more involvement with what the user does, until there's
another request. So PHP cannot directly react to the user moving the mouse over
a part of the user interface of whatever browser they're using. The user would
have to click a link or submit a form for a pure PHP solution.

--
Andy Hassall (an**@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #3
Andy wrote:
On Thu, 9 Oct 2003 20:04:58 -0500, "Richard" <anom@anom> wrote:
I'm beginning to undertake php for the fun of it. Working on a problem I hope can be solved in php.
Basically what I have is this: <body> <img name="main" src="image1.jpg ">
<a href="#"
onMouseOver="do cument.main.src ='image2.jpg'"
onMouseOut="doc ument.main.src= 'image1.jpg'">o ne</a> </body> Ok I know, shoot me. I know "name" is not a valid attribute No firearms required; it's perfectly valid. <img> does have a name
attribute. http://www.w3.org/TR/html4/struct/objects.html#h-13.2 How would I go about converting this same effect to PHP?

Once the HTML (or whatever you've output with PHP) has been sent to
the
browser, PHP has no more involvement with what the user does, until
there's
another request. So PHP cannot directly react to the user moving the
mouse over
a part of the user interface of whatever browser they're using. The
user would
have to click a link or submit a form for a pure PHP solution.


Thanks. I found a way out of it and it even validates.
onmouseover="do cument.images[0].src='image2.jp g' "
onmouseout="doc ument.images[0].src="image1.jp g' "
Jul 17 '05 #4
Carved in mystic runes upon the very living rock, the last words of Richard
of comp.lang.php make plain:
Thanks. I found a way out of it and it even validates.
onmouseover="do cument.images[0].src='image2.jp g' "
onmouseout="doc ument.images[0].src="image1.jp g' "


Just so you understand, that is JavaScript, not PHP.

Hmmm, an interesting idea, though: client-side PHP.

Nah!!!

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
Jul 17 '05 #5
I have a PHP function in an include file that allows you to do this, but
in reality, all it does is output the code for the Javascript mouseover
effect... The rollover() function is copied below (with CppDoc
compatable documentation comment)

Cheers,
Daniel
-Snip-

/*************** *************** *************** *************** *************** **
Creates a rollover button
@param $image_1 Name of the default image
@param $image_2 Name of the image to display when the mouse passes over
the image
@param $urllink Path or object that the text will be linked to
@param $ftarget Frameset target if used in a frame. If nothing is
specified, the target will not be used. If nothing is specified, and the
page is contained within a frame, the pane that contains the page that
uses this function will be replaced by the object defined in $linkpath.
@return Nothing
@since 1.0
*************** *************** *************** *************** *************** **/
function rollover($image _1,$image_2,$ur llink,$ftarget= "")
{
if ($ftarget != "") {
$ftarget = " target=\"$ftarg et\"";
}
echo <<<ROLLOVERHT ML
<a href="$urllink" $ftarget onMouseOver= "if (document.image s)
document.image1 .src= '$image_2';" onMouseOut= "if (document.image s)
document.image1 .src= '$image_1';"><i mg src= "$image_1" name="image1"
border=0></a>
ROLLOVERHTML;

print("<script language=\"java script\"><!-- if (document.image s) { var
IMAGE1=new Image();IMAGE1. src=\"$image_2\ ";}//--></script>");
}

-Snip-

Richard wrote:
I'm beginning to undertake php for the fun of it.

Working on a problem I hope can be solved in php.
Basically what I have is this:

<body>

<img name="main" src="image1.jpg ">
<a href="#"
onMouseOver="do cument.main.src ='image2.jpg'"
onMouseOut="doc ument.main.src= 'image1.jpg'">o ne</a>

</body>

Ok I know, shoot me. I know "name" is not a valid attribute but it works.
If I use "ID" it does not work.

How would I go about converting this same effect to PHP?


Jul 17 '05 #6

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

Similar topics

2
1584
by: uNConVeNtiOnAL | last post by:
Hi - I have a page that has a button that makes a prompt appear for the user to type input. When they have typed in input, I want the button to change color when the prompt closes. I am trying to do image swapping This snippet will prevent 'null' from appearing initially and successfully records user changes (typing in a comment)
3
6165
by: Randell D. | last post by:
Folks, I'm still learning javascript - I've invested in a couple of books and reading online as much as possible. I'm pretty sure what I am suggesting is possible though I'm trying to weigh up the faults that might go with the suggestion... all opinions welcome. My question: I have a list of links that go to pages that have a similar layout. Could I have a text swap, similar to what I've seen with image swaps (or an image switch)...
8
3908
by: TheKeith | last post by:
I'm doing an image cycler but can't figure out why it keeps getting hung up on the third pic in the array? Here is what I have: ---------------------------------------------------------------------------- --------------------------------- <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
8
5506
by: OysterCracker | last post by:
Hi - I've previously used js to swap images on mouseover in a menu. I'm stumped on a different situation and would appreciate some advice. I would like to swap imageA to ImageB when I mouseover imageC. Also, swap imageA to ImageB when I mouseover a text link. How do I do those? Thanks, ~OC~
2
1123
by: Richard | last post by:
www.somestuff.batcave.net/test1.html I have the major part of this monster worked out. Changing categories is fine. Only thing is, I get nothing when I click on a thumbnail. I know the value is being passed properly because I've used "alert" blocks to tell me that. Until I get something better to use for the swapping, I'm just using the bare basic routine.
6
2267
by: cjl | last post by:
I have a website which allows people to view interesting radiology cases. It is for teaching radiology residents. It is designed to run in fullscreen or 'kiosk' mode, at 1024 x 768 resolution only. http://www.casespace.net I designed it with firefox (plus the autohide extension) in mind, but also want to support IE. Online and offline it works great in Firefox. Offline it also works
7
9108
by: cjl | last post by:
OK: I am really scratching my head over a preload / image swapping problem, so I started conducting experiments: http://www.saintrays.net/experiment1.html http://www.saintrays.net/experiment2.html http://www.saintrays.net/experiment3.html View the source of each page to see the relevant javascript. All three
5
2245
by: Guadala Harry | last post by:
In an aspx page I have declared an Image control: <asp:Image id="myImage" runat="server"></asp:Image> In the code-behind I populate it's ImageURL property, like this: myImage.ImageUrl = "some.gif"; Then, in client-side JavaScript, the user can cause the image to be replaced, like this: document.all("myImage").src = "other.gif";
2
2928
by: guywmustang | last post by:
So, basically this is the problem. I have this... <div id="mainframe"> <img src="image.jpg" id="image"> </div> Then when I try to in a function say... function checkImage()
3
5669
by: seamlyne | last post by:
The first method I ever used for multiple state buttons was to create a graphic for each button for each state: AboutUs_on, AbooutUs_over, AboutUs_out, etc. That works great when there are just a few buttons. I'm creating interfaces now with many more buttons than "just a few". I solved the maintenance problem by having generic button images, one for each state, and having them be background images for text containers, DIVs in this...
0
9431
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10014
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9689
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8688
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6514
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5289
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3780
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3326
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2647
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.