02.22.08

How to get jsp session variables in java script

Posted in JavaScript at 8:17 pm by vchaithanya

<%String s=(String)request.getSession().getAttribute(“color”); %>

<script type=“text/javascript”>

var val=<%=s %>;

var n=document.getElementById(’system_content_prod’);

alert(“cnya:”+val+” : “+n);

n.style.background=val;

</script>

Change the background color by taking RGB values as input

Posted in JavaScript at 5:16 am by vchaithanya

<html>
<head>
<style type=”text/css”>
body
{
background-color:#B8BFD8;
}
</style>
<script type=”text/javascript”>
function changeStyle()
{

document.body.style.backgroundColor=”rgb(“+document.forms[0].c1.value+”,”+document.forms[0].c2.value+”,”+document.forms[0].c3.value+”)”;
}
</script>
</head>
<body>
<form name=”form1″>
<input type=”text” name=”c1″ value=”0″/>
<input type=”text” name=”c2″ value=”0″/>
<input type=”text” name=”c3″ value=”0″/>
<input type=”button” onclick=”changeStyle()” value=”Change background color” />
</form>
</body>
</html>