You need to sign in to do that
Don't have an account?
Eelco Litjens
auto select checkbox in VF page
I would like to auto-select a checkbox .....i am not so well known with code.
is this something i can use? How must i write this?
is this something i can use? How must i write this?
<apex:actionFunction value="{!item.Alert_SMS_sent__c}" immediate="true" />
what is the condition for autoselect ? you can set the attribute using
selected = true if using apex:checkbox...based on your condition you an do this...if on load itself you want that checkbox to be checked then you can put selected=true...
Please check adn let me know if it helps.
Thanks.,
Sandeep
thanks
1. After pressing the button in code you can get the checkbox DOM like
<apex:checkbox id='Test' value="{!}"/>
you can get like document.getElementById('Test').selected =true;
Like that you can set the attribute anytime you want..
Thanks,
Sandeep
This is the action function which does the processing when we click on button right..so oncomplete of this button you need toi call one javascript method where you will get nad set the value
<apex:actionFunction value="{!item.Alert_SMS_sent__c}" immediate="true" oncomplete="setCheckboxValue();"/>
define once function in javascript
<script>
function setCheckboxValue()
{
document.getElementById('Test').Selected = true;
}
</script>
here test is that checkbox id..
Please check adn let me know if it helps you..
Thanks,
Sandeep
many thanks. where do i put this? in the VF page? or seperately somewhere? if i put this in the VF page i get error Error: Unsupported attribute value in <apex:actionFunction> in SendSMS at line 13 column 120
so you should call some class method and that method will do the rest functionality and whatever is your need...
so if you have function in class then provid ethat name..
else create one function in class and provide the name in value
class:
public void sendEmail()
{
}
<apex:actionFunction value="{!sendEmail}" immediate="true"oncomplete="setCheckboxValue();"/>
Like I mentioned these are the correct syntaxes for these..
Thanks,
Sandeep
thanks already for your patience and help.. :-)
first code is class:
second code is VF page:
it should be action instead of value
thanks
<apex:actionFunction action="{!setCheckboxValue}" immediate="true"oncomplete="setCheckboxValue(); rerender="textSection"
I am not able to find your checkbo which you wany to auto select ? can you please share the code of checkbox
so in the code, i used item.Alert_SMS_sent__c
where is your checkbox in vf page ?
you ahev not defined the checkbox...so
But still getting an error: [Error] Error: SendSMS line 14, column 79: Element type "apex:actionFunction" must be followed by either attribute specifications, ">" or "/>"
[Error] Error: Element type "apex:actionFunction" must be followed by either attribute specifications, ">" or "/>".
Replace actionfunction with this
Thanks
the error is:
Error: SendSMS line 14, column 62: Element type "apex:actionfunction" must be followed by either attribute specifications, ">" or "/>"
[Error] Error: Element type "apex:actionfunction" must be followed by either attribute specifications, ">" or "/>".
Class code:
VF code:
sorry for the "noob" level :-)
here is teh mistake, in rerender only elemsnt Id we should pass like textSection which is pageblock id....value we should not pass there....