0

I have a problem with checkboxes: I have 2 menu that open 2 type of checkbox and I would like to have one all checked and the other not-checked when I refresh the page. this is the code:

<div id="Scena" class="tabcontent" onmousedown="if (event.preventDefault) event.preventDefault()">
    <input type="checkbox" checked="checked" style="cursor:hand;" onclick="presenter.toggleInstanceVisibilityByName('Parete_frontale',true);"> Parete_frontale </input>
    <input type="checkbox" checked="checked" style="cursor:hand;margin-left:50px;" onclick="presenter.toggleInstanceVisibilityByName('Parete_destra', true);"> Parete_destra </input>
    <input type="checkbox" checked="checked" style="cursor:hand;margin-left:50px;" onclick="presenter.toggleInstanceVisibilityByName('Parete_sinistra', true);"> Parete_sinistra </input>
    <input type="checkbox" checked="checked" style="cursor:hand;margin-left:50px;" onclick="presenter.toggleInstanceVisibilityByName('Parete_p1', true);presenter.toggleInstanceVisibilityByName('Parete_p2', true);presenter.toggleInstanceVisibilityByName('Parete_p3', true);"> Parete_porta </input><br/> 
</div>

<div id="Indagini" class="tabcontent">
    <input type="checkbox" style="cursor:hand;" onclick="presenter.changeTexture('Parete_p2','back01_cervo.png');setInfoSofia(4);"> Image enhancement </input>
    <input type="checkbox" style="cursor:hand;" onclick="presenter.changeTexture('Parete_destra', 'destra_fluo.png');setInfoSofia(5);"> Analisi di Fluorescenza (LIF) </input>
    <input type="checkbox" style="cursor:hand;" onclick="setInfoSofia(6)"> Efflorescenze saline </input>
    <input type="checkbox" style="cursor:hand;" onclick="presenter.toggleSpotVisibility(HOP_ALL, true); presenter.enableOnHover(!presenter.isOnHoverEnabled()); hotspotSwitch();"> Indagini di caratterizzazione dei materiali </input>
</div>

I want all children of the div with id Scena to be checked and those of the div with id Indagini to be unchecked. Can anyone help me?

5
  • 1
    First of all, input is an empty tag, it can't have content nor closing tag. Use checked attribute to mark an input checked. Note also, what is said about FireFox concerning page refreshing and checked attribute in the documentation. Commented Jun 21, 2017 at 8:52
  • <div id="Scena" class="tabcontent" > <input type="checkbox" checked="checked" style="cursor:hand;" onclick="presenter.toggleInstanceVisibilityByName('Parete_frontale',true);"> Parete_frontale </input> <input type="checkbox" checked="checked" style="cursor:hand;margin-left:50px;" onclick="presenter.toggleInstanceVisibilityByName('Parete_destra', true);"> Parete_destra </input></div> Commented Jun 21, 2017 at 9:01
  • this is part of the code with the attribute "checked" but i want it also at the page refresh Commented Jun 21, 2017 at 9:02
  • Please don't dump code snippets to comments, edit the question instead. Commented Jun 21, 2017 at 9:02
  • @Sofia_C, i see [javascript] tag at the bottom of your question. i guess you could write js function which will refresh your checkboxes on page load Commented Jun 21, 2017 at 9:08

1 Answer 1

1

You can use "checked" option.So, by default all the Scena checkboxes will be checked.

<input type="checkbox" checkedstyle="cursor:hand;" onclick="" checked> Image enhancement 
Sign up to request clarification or add additional context in comments.

5 Comments

for the id "Scena" i have done it, my problem is for the page refresh. I want one menu all checked and the other non checked.
You can use jquery checked option, ('.ScenaClass').prop('checked', true); and ('.IndaginiClass').prop('checked', false); This can be done by giving the class to all the checkbox inside the Scene one.
Still, there is no such thing as a </input>.
Yes, OP need to remove </input> :)
Welcome,Let me know if there is any issues. $('.ScenaClass').prop('checked', true); forgot to add $ in the previous comment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.