You need to sign in to do that
Don't have an account?

Interacting with VisualForce with JavaScript
Hi All,
I am trying to change the value of the outputlabel component with id="id1"through the jquery/javascript.But I am not able to do so. The VF page is below:
<apex:page standardController="Account">
<apex:includescript value="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" />
<script>
function display(c,sd){
var $j=jQuery.noConflict();
if(c.checked)
{
alert($j('[id*=sd]').val());
}
else
{
alert("Unchecked");
}
}
</script>
<apex:pageBlock id="thepageBlock">
<apex:outputLabel id="id1" value="Checkbox" for="id6"/>
<apex:pageBlockSection id="id2">
<apex:pageBlockSectionItem id="id3">
<apex:outputText id="id4" value="Hello World!!"/>
<apex:form id="id5">
<apex:inputCheckbox id="id6" value="{!account.name}" Onclick="display(this,'id1')"/>
</apex:form>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
Actually when try read the value with the help of alert box if gives me nothing.
I am not able to figure out what is the issue here .
So it will be very helpfull if I am given a knowledge of how to change the Vf component with javascript.
Thanks
Saurabh
I am trying to change the value of the outputlabel component with id="id1"through the jquery/javascript.But I am not able to do so. The VF page is below:
<apex:page standardController="Account">
<apex:includescript value="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" />
<script>
function display(c,sd){
var $j=jQuery.noConflict();
if(c.checked)
{
alert($j('[id*=sd]').val());
}
else
{
alert("Unchecked");
}
}
</script>
<apex:pageBlock id="thepageBlock">
<apex:outputLabel id="id1" value="Checkbox" for="id6"/>
<apex:pageBlockSection id="id2">
<apex:pageBlockSectionItem id="id3">
<apex:outputText id="id4" value="Hello World!!"/>
<apex:form id="id5">
<apex:inputCheckbox id="id6" value="{!account.name}" Onclick="display(this,'id1')"/>
</apex:form>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
Actually when try read the value with the help of alert box if gives me nothing.
I am not able to figure out what is the issue here .
So it will be very helpfull if I am given a knowledge of how to change the Vf component with javascript.
Thanks
Saurabh
Use this code to change the value of the outputlabel component with id="id1".
<apex:inputCheckbox id="id6" value="{!account.name}" Onclick="change()"/>
<script>
var $j=jQuery.noConflict();
function change()
{
$j('[id*=id1]').html("changed");
}
</script>
Thanks
This filled the gap in my understanding and helped me in understanding the crux.
Definetly it works!