Error when prechecking checkbox

Avatar

Avatar
Validate 1
Level 1
bryceh57660644
Level 1

Like

1 like

Total Posts

16 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
bryceh57660644
Level 1

Like

1 like

Total Posts

16 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
bryceh57660644
Level 1

02-10-2020

I am getting this error when I enter debug mode on my webapp with the checkbox:

bryceh57660644_0-1601670556100.png

 

I tested the logic as a text field and it is passing through fine, so it is something to do with my checked logic, but I cannot figure out why.

 

Java script is: 

document.getElementById("control_San")[0].checked = "<%=ctx.vars.San%>"

 

in the HTML <body>, this is corresponding code: 

<tr>
<td style="padding: 5px 0px 0px 25px;">
<div id="control_San" style="position: relative; overflow: hidden; margin: 5px 3px 5px 0px; font-weight: bold; text-decoration: none; font-style: normal; color: #ffffff;"><input name="San" id="control_San" style="border-radius: 6px; margin: 0 3px 5px 0px; width: 50px;" type="checkbox" label="San" />Increased sanitation measures</div>
</td>
</tr>

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
MVP
wodnicki
MVP

Likes

977 likes

Total Posts

1,096 posts

Correct reply

516 solutions
Top badges earned
Establish
Affirm 500
Contributor
Shape 1
Give Back 100
View profile

Avatar
Establish
MVP
wodnicki
MVP

Likes

977 likes

Total Posts

1,096 posts

Correct reply

516 solutions
Top badges earned
Establish
Affirm 500
Contributor
Shape 1
Give Back 100
View profile
wodnicki
MVP

07-10-2020

Hi,

 

Move the JS to the bottom of the page, or add to $(function(){}), or just inline into the DOM itself instead of using JS:

<input name="San" id="control_San" style="border-radius: 6px; margin: 0 3px 5px 0px; width: 50px;" type="checkbox" label="San" checked="<%=ctx.vars.San%>"/>

 

Thanks,

-Jon

Answers (3)

Answers (3)

Avatar

Avatar
Give Back 50
Employee
Sukrity_Wadhwa
Employee

Likes

157 likes

Total Posts

927 posts

Correct reply

35 solutions
Top badges earned
Give Back 50
Validate 1000
Validate 500
Validate 250
Validate 100
View profile

Avatar
Give Back 50
Employee
Sukrity_Wadhwa
Employee

Likes

157 likes

Total Posts

927 posts

Correct reply

35 solutions
Top badges earned
Give Back 50
Validate 1000
Validate 500
Validate 250
Validate 100
View profile
Sukrity_Wadhwa
Employee

21-10-2020

Hi @bryceh57660644

Were you able to resolve this query with any of the given solutions? Do let us know.

Thanks!

Avatar

Avatar
Give Back 5
Level 4
prasannakumarmarru
Level 4

Likes

51 likes

Total Posts

59 posts

Correct reply

17 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 10
Give Back
Boost 50
View profile

Avatar
Give Back 5
Level 4
prasannakumarmarru
Level 4

Likes

51 likes

Total Posts

59 posts

Correct reply

17 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 10
Give Back
Boost 50
View profile
prasannakumarmarru
Level 4

03-10-2020

Hib @bryceh57660644 

I think Script is running even before the html element is rendered into document. You can try moving the script to different places than where you have it now?

Avatar

Avatar
Affirm 100
MVP
_Manoj_Kumar
MVP

Likes

117 likes

Total Posts

329 posts

Correct reply

102 solutions
Top badges earned
Affirm 100
Validate 1
Contributor
Ignite 1
Shape 1
View profile

Avatar
Affirm 100
MVP
_Manoj_Kumar
MVP

Likes

117 likes

Total Posts

329 posts

Correct reply

102 solutions
Top badges earned
Affirm 100
Validate 1
Contributor
Ignite 1
Shape 1
View profile
_Manoj_Kumar
MVP

03-10-2020

Hello @bryceh57660644 

 

What are you trying to do with the javascript code?

In the HTML code, I see only one checkbox but the javascript is trying to do something with the first checkbox among multiple checkboxes with the same id.

 

Can you share your full code?

 

Thanks,

Manoj