hii this my code.the problem is i'm changing the background color for an header using on click function in javascript.but wen i did page refreshing the default background color is appearing.i want to dislay the changed background color of that header wen once on click function is done. please help me.

<script type="javascript">
function background()
var x= document.getElementById('d1').value;
if(x !='NULL')
<form action"1.php" Method="post">
<h1 id="h1" style="background:black"> Hi How r U frends </h1>
<input type="radio" value="changebg" name="d1" id="d1" on click="background()">display Message
<input type="radio" value="changebg" name="d1" id="d1" on click="background()">display Message

here the default background color of h1 is balck.by clicking the radio button the background was  
changing into green.i want to display the h1 with green back ground upto session ends & even after 
page refreshing.help me......
many thanx to all
4 Years
Discussion Span
Last Post by diafol

use a cookie to hold the information about what the background colour is and use it if it is available on page load. You can also use localStorage or a database (indexdb or websql) for the same purposes.


hi diafol..can u please wrote a piece of code for how to store & retrive the data from cookies.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.