0

i try to get the value from <input type="checkbox">and pass it to my variable on controller but i always get 'Argument cannot be null'. i already try using inputHidden to <select> tag and <input type="text"> and it works but why it didn't work on <input type="checkbox">.

Did i do it correctly ? i do it based on Get text input value with the help of HTML and pass it to controller answer

--Visualforce--

<apex:inputHidden value="{!CC}" id="ccId"/> 
<label><input type="checkbox" onchange="document.getElementById('{!$Component.ccId}').value = this.value;" />Kartu Kredit</label> 

--Apex Class--

public Boolean CC{get;set;}
public PageReference Submit(){
   web2lead.Credit_Card__c =CC;
   update web2lead;
}

1 Answer 1

1

Use this.checked instead this.value

We know in case of checked box, we need to check checked attribute not value.

if it a input type="text" then we need to use value

<apex:inputHidden value="{!CC}" id="ccId"/> 
<label><input type="checkbox" onchange="document.getElementById('{!$Component.ccId}').value = this.checked;" />Kartu Kredit</label>

Class

public Boolean CC{get;set;}
public PageReference Submit(){
   web2lead.Credit_Card__c =CC;
   update web2lead;
}
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.