**disclaimer: I can't find any docs on this but as usual, if it exists I would be delighted to get the location.**
Hi,
I am trying to get a mktoBoolean to be a trigger in a if statement but I can't get it to work.. see code below, any ideas?
<meta class="mktoBoolean" id="show_sidebar" mktoName="Show sidebar?" default="true" true_value="block" false_value="none" false_value_name="Hide" true_value_name="Show">
<script>
if (show_sidebar === false) {
document.getElementById(main-content-id).style.width=100%;
} else {}
</script>
kundly, jonas.
Solved! Go to Solution.
Has nothing to do with XHR cross-domain security.
The problem is actually quite basic. This is not a valid style assignment:
// broken, you can't assign CSS text here
document.getElementById('main-content-id').style.width = '100% !important';
That line is valid JavaScript, but it doesn't actually do anything. You can't simply assign the CSS text '100% !important' as if it's the value of the width property. It's actually two values, one being the '100%' and the other being the special reserved priority attribute (whose only allowed value is the string 'important').
To set !important in script, use setProperty, which includes the priority:
document.getElementById('main-content-id').style.setProperty('width','100%','important')
sorry to say it's not working either
did not work...
using this code now:
<script>
if ('${show_sidebar}' == 'none') {
document.getElementById('main-content-id').style.width = "100% !important";
} else {}
</script>
PS: is main-content-id is the ID, then you should write it
if ('none' == 'none') {
document.getElementById("main-content-id").style.width=100%;
} else {}
-Greg