473,387 Members | 1,592 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,387 software developers and data experts.

Same effect but when page reloaded?

Hi,

I wrote a this piece of code in let's say page1.php:
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript">
  2. function bgi01(){
  3.     document.getElementById('changeThisBG01').style.backgroundImage='URL(mp02.jpg)';
  4.     document.getElementById('changeThisBG02').style.backgroundImage='URL(mp01.jpg)';}
  5. function bgi02(){
  6.     document.getElementById('changeThisBG02').style.backgroundImage='URL(mp02.jpg)';
  7.     document.getElementById('changeThisBG01').style.backgroundImage='URL(mp01.jpg)';}
  8. </script>
  9. <table width="185" border="0" cellpadding="0" cellspacing="0">
  10.   <tr> 
  11.     <td width="185" height="165" valign="center" align="center" id="changeThisBG01" style="background-image: url(mp01.jpg); background-repeat:repeat-x;"><a href="javascript:bgi01()">BG1</a></td>
  12.     <td width="185" height="165" valign="center" align="center" id="changeThisBG02" style="background-image: url(mp01.jpg); background-repeat:repeat-x;"><a href="javascript:bgi02()">BG2</a></td>
  13.   </tr>
  14. </table>
  15.  
My question:

This codes excecutes without pagereload.
Any suggestion how i could make the same effect but with this difference that the page is reloaded? <href="page1.php">

Thanx for help.

Thoaren
Apr 11 '06 #1
1 1355
Banfa
9,065 Expert Mod 8TB
Erm how much php do you know?

Write a php script that accepts a variable on the url of the web page (this is really simple) and then acts on that variable to output the code to display different backgrounds.

Something like this

[php]
<?php
$image1 = "mp01.jpg";
$image2 = "mp01.jpg";

if (isset($_GET['replace'] )
{
if ( $_GET['replace'] == 1 )
{
$image1 = "mp02.jpg";
}
else if ( $_GET['replace'] == 2 )
{
$image2 = "mp02.jpg";
}
}
?>
<head>
<style>
#changeThisBG01 {
background-image: url(<?php echo $image1; ?>);
background-repeat: repeat-x;
}
#changeThisBG02 {
background-image: url(<?php echo $image2; ?>);
background-repeat: repeat-x;
}
</style>
</head>
<body>

<table width="185" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="185" height="165" valign="center" align="center" id="changeThisBG01"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?replace=1">BG1</a></td>
<td width="185" height="165" valign="center" align="center" id="changeThisBG02"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?replace=2">BG2</a></td>
</tr>
</table>
</body>[/php]
Apr 11 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ian.H | last post by:
Hi all, I've been testing out some configs on this box out of curiousity more than anything, but looking at various sites and of course, php.net regarding safe_mode_exec_dir, it appears that if...
33
by: Philip Herlihy | last post by:
I'm creating a common navigation bar of text "buttons" using CSS. On each page, I want the corresponding button to be "inert" (no hover, etc) as a visual clue to where you are. I thought I'd...
1
by: krian | last post by:
Hi, I need a help from anybody. My problem is here I wrote two WebApplication in ASP.net Using C#. The name of the applications are (Journal.aspx and Payment.aspx). These Two pages have DataGrids...
3
by: Richard | last post by:
Hey there, I have a textbox and a listbox. When a user types a number in the textbox, I want to get all the records from a MS Access DB but without reloading the page. I now have something...
1
by: Lenard Gunda | last post by:
Hi! I have the following problem. From my main page, when someone clicks a button, it uses client side javascript to open another .aspx page. This page displays content, based on what the...
2
by: Thoaren | last post by:
Hi, I wrote a this piece of code in let's say page1.php: <script language="JavaScript"> function bgi01(){ document.getElementById('changeThisBG01').style.backgroundImage='URL(mp02.jpg)';...
3
by: Bob Sanderson | last post by:
I am trying to create a form for a MySQL database similar to a spreadsheet. The idea is to display a list of records, with the last line of the list being an input form. When the user enters data...
5
dmjpro
by: dmjpro | last post by:
i saw some magic web pages ..... when press back button then the same page again and again reloaded ... is it possible in js ...... plz help me out ... thanx in advnace .......
5
by: OBAFGKM_RNS | last post by:
I have a javascript timer on my page that counts to 10. Every half second it alternates images on my buttons from a lighter image to a darker image, giving the appearance of the buttons blinking....
7
by: TomDestry | last post by:
I have a web page and lots of XML files. When a link is clicked on the page, it calls a function via onclick with the XML file as a parameter: <body onload="InitContent();"> <a name="fileName"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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...

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.