how to store html checkbox values in html field

Arjun Kumar Le1
Tera Contributor

I have html code which have checkboxes when i check and save the incident the checkboxes that was selected before was unchecked. how to store that data like here i check test 1 and when i save the test1 is unchecked but i want to save the data.

ArjunKumarLe1_0-1686163974811.png

 

 

html code:

<ul style="list-style-type: none;">
<li><input type="checkbox" />Test 1</li>
<li><input type="checkbox" />Test 2</li>
</ul>

 

 

1 ACCEPTED SOLUTION

@Arjun Kumar Le1 it's not possible to achieve that.

 

Please mark as correct answer if this helped you.

View solution in original post

7 REPLIES 7

Marco0o1
Tera Sage

Hi @Arjun Kumar Le1 ,

 

If you are using widgets you need to use directives, in your HTML tried something like this:

 

 

 

<ul style="list-style-type: none;">
<li><input type="checkbox" ng-modal="c.test1" />Test 1</li>
<li><input type="checkbox" ng-modal="c.test2" />Test 2</li>
</ul>

<pre> The test 1 value is: {{c.test1}} and the test 2 value is: {{c.test2}} </pre>

 

 

 

In your client-script just define you c variable:

 

 

 

api.controller=function() {
	/* widget controller */
	var c = this;
       c.test1 = false; // you dont need to add this but is a good practice
       c.test2 = false;  //you can change to true and in the load page would be checked
};

 

 

 

Hope that can help you.

This is not in portal, this is in back end form.

jaheerhattiwale
Mega Sage

@Arjun Kumar Le1 Its not possible. The html field will take static value. It will be dynamic.

 

If you want to achieve something like this then you need to add 2 new boolean fields (Test 1, Test 2).

 

Write onchange client script in both fields.

When "Test 1" field is changed and its true set below code in HTML field

<ul style="list-style-type: none;">
<li><input type="checkbox" checked="checked"/>Test 1</li>
<li><input type="checkbox" />Test 2</li>
</ul>

 

If "Test 2" field is changed and its true then 

<ul style="list-style-type: none;">
<li><input type="checkbox" />Test 1</li>
<li><input type="checkbox" checked="checked" />Test 2</li>
</ul>

 

Please mark as correct answer if this solves your issue.

 

there is no field related to this, these are only two html contents test1 and test 2 , after checke them save i need to save the at true check or false check, please guide me how to do this