0% found this document useful (0 votes)
81 views

CSS 10th Practical

Css manual code and Output
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views

CSS 10th Practical

Css manual code and Output
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1.

Code
<html>
<body>
<form name="myform">
Name: <input type="text" name="cname"> <br><br>
Value: <input type="text" name="cvalue"> <br><br>
<input type="button" onclick="writeCookie()" value="Write">

<p id="disp"> </p>


</form>
<script>

function writeCookie()
{
var cname = document.myform.cname.value;
var cvalue = document.myform.cvalue.value;

document.cookie = cname + "=" + cvalue;


readCookie();
}

function readCookie()
{
var disp = document.getElementById("disp");

disp.innerText = document.cookie;
}

readCookie();
</script>
</body>
</html>
Output
2. Code

<html>
<body>
<form name="myform">
Name to Delete: <input type="text" name="cname"> <br><br>
<input type="button" onclick="deleteCookie()" value="Write">

<p id="disp"> </p>


</form>
<script>

function deleteCookie()
{
var cname = document.myform.cname.value;

document.cookie = cname + "= ; expires = Wed, 11 Aug 2024 12:00:00 UTC";


readCookie();
}

function readCookie()
{
var disp = document.getElementById("disp");

disp.innerText = document.cookie;
}

readCookie();

</script>
</body>
</html>
Output
3. Code

<html>
<body>
<form name="myform">
Name:<br> <input type="text" name="cname"> <br><br>
Value:<br> <input type="text" name="cvalue"> <br><br>
Expiry:<br> <input type="datetime-local" name="cexpiry"> <br><br>

<input type="button" onclick="setCookie()" value="Write">

<p id="disp"> </p>


<p id="disp2"> </p>
</form>
<script>

function setCookie()
{
var cname = document.myform.cname.value;
var cvalue = document.myform.cvalue.value;
var cexpiry = document.myform.cexpiry.value;

var d = new Date(cexpiry);


var exp = d.toUTCString();

var str = cname + "=" + cvalue + "; expires=" + exp;


document.getElementById("disp2").innerText = str;
document.cookie = str;
readCookie();
}

function readCookie()
{
var disp = document.getElementById("disp");

disp.innerText = document.cookie;
}

readCookie();

</script>
</body>
</html>

Output

You might also like