Print Page | Close Window

Checkbox element

Printed From: openElement Website
Category:

openElement


Forum Name: Scripts for Your Website
Forum Description: Samples of scripts you can insert on your website using the element 'block of code.'
URL: https://forums.openelement.uk/en/forum_posts.asp?TID=1949
Printed Date: Apr 19 2024 at 9:33pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Checkbox element
Posted By: Yves21
Subject: Checkbox element
Date Posted: Feb 13 2023 at 1:33pm
Hello 
I'm tring to use checkbox from thr element panel but impossible to select it by Id

function action() {
var checkBox = document.getElementById("#WEcase");
if (checkBox.checked == true){
    alert("Saved!");
}
nothing when i call the funcion
WEcase is the id of my checkbox element
can you help me telling what is wrong in the code
Thanks
Yves




Replies:
Posted By: Hobby001
Date Posted: Feb 14 2023 at 1:27pm
Good question, thanks.

openElement use to embed elements within a div and give this div the ID

<div id="WEcase" class="BaseDiv RNone OEWECheckBoxV2 OESK_WECheckBox2_Default" style="z-index:1">
<div class="OESZ OESZ_DivContent OESZG_WEcase ">
<input type="checkbox" class="OESZ OESZ_CheckBox OESZG_WEcase  OEDynTag0" name="WEcase " value="" />
</div>
</div>

Therefore you have to add the child element input in the element selector $("#WEcase").

Here is some jQuery code to use:

function action(){
if($("#WEcase input").prop("checked")){
alert ("saved");
}
}

$("#WEcase").click(function(){
action();
});


-------------
https://denislafrance.net/index.en.php" rel="nofollow - https://denislafrance.net https://www.youtube.com/playlist?list=PLWg7A6YtIr7WE2oJe9pX8_3u0FerqJwjo" rel="nofollow - , OE training video


Posted By: Yves21
Date Posted: Feb 14 2023 at 9:21pm
Many thanks, it worksBig smile


Posted By: Hobby001
Date Posted: Feb 15 2023 at 6:13pm
You're welcome, that's the purpose of this Forum

-------------
https://denislafrance.net/index.en.php" rel="nofollow - https://denislafrance.net https://www.youtube.com/playlist?list=PLWg7A6YtIr7WE2oJe9pX8_3u0FerqJwjo" rel="nofollow - , OE training video



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net