You need to sign in to do that
Don't have an account?
sp13
how to pass javascript variable to apex variable
how can i pass a javascript variable to apex variable?
i need to use the apex variable on the if condition for list item class style.
PAGE:
i need to use the apex variable on the if condition for list item class style.
PAGE:
<ul> <li class="{!IF(a==true && b==false, 'tabStyle1', 'tabStyle2')}"> P&L Entry </li> <li class="{!IF(a==false && b==true, 'tabStyle1', 'tabStyle2')}"> P&L Search </li> </ul> <div id="DivID1"> text1 </div> <div id="DivID2"> text2 </div>
<style> .tabStyle1 { backgroound-color: red; } .tabStyle2 { backgroound-color: blue; } </style> Controller:
public String a {get;set;} public String b {get;set;} public void showA() { //a = __________; <----pass this javascript: $("#DivID1").is(":visible"); //b = __________; <----pass this javascript: $("#DivID2").is(":visible"); }
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
function populate()
{
var a;
var b;
$("[id$='a_id']").val(a); //pass value to a from var a
$("[id$='b_id']").val(b); //pass value to a from var b
}
</script>
<apex:inputHidden value="{!a}" id="a_id"/>
<apex:inputHidden value="{!b}" id="b_id"/>