Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

how to disable radio buttons or check box in SSI Web 7....getElementById dose not working

Can anyone plz tell me how to disable radio button or chekbox in SSI Web 7.
As in this new version grafical buttons are used so it seems quite difficult to find right id of button.

it is not done by  getElementById..

Please give me the solution.
asked Jan 11, 2012 by Gaurav (260 points)
edited Jan 11, 2012 by Walter Williams

1 Answer

0 votes
 
Best answer
you need to find and modify the div elements named graphical as well. For example for a "select" question named "TYPE", this is how you would hide the graphical checkbox
document.getElementById("TYPE_2_graphical").visibility = 'hidden';
document.getElementById("TYPE_2_graphical").disabled = 'true';
document.getElementById("TYPE_2_graphical").className = 'HideElement';


you need to do this for the label text as well.
answered Jan 11, 2012 by Bahadir Ozkurt Gold (16,930 points)
thanx Bahadir Ozkurt (v7)....as i apply your script ,it results hiding the checkbox.
But
 i want it to visible but disable......
it dose not get disable by  this id ->
document.getElementById("TYPE_2_graphical").disabled = 'true';

CAN YOU PLEASE GIVE ME THE EXACT SOLUTION........(JUST TO DISABLE THE CHECKBOX)
hi Gaurav, the code below makes the graphical checkbox not clickable, BUT ONLY VISUALLY. the checkbox behind it gets checked in the background if you click the text next to the checkboxes. so you need to disable the nongraphical boxes as well, i.e. getElementById("TYPE_2").disabled = 'true'; hope this helps
document.getElementById("TYPE_2_graphical").className = 'checkbox';
hi Bahadir Ozkurt

No its not working for disableing the checkbox.i have tried this code.

In sawtooth7, checkbox can be hidden but can not be disabled by the above suggestions.
can you please post your question name and whole script?
Question name:->TYPE
this is select type question with checkbox.


i had put the below script in footer to disable the checkbox.but it is not  working.


<script>
document.getElementById("TYPE_2_graphical").disabled = 'true';
document.getElementById("TYPE_2_graphical").className ='checkbox';
document.getElementById("TYPE_2").disabled = 'true';
</script>
weird, I kinda remember that to have worked before. anyway
document.getElementById("TYPE_2_graphical").parentElement.parentElement.className = '';

works, I have tried it. IT makes the whole row of 2nd choice unclickable. at least for me :)
ok thank u so much Mr.Bahadir Ozkurt.
It works fine now.
Mr.Bahadir Ozkur can u tell me on more ans plz:-
if i want that on clicking on first checkbox ,second checkbox would disable then what to do.
<script>

var ch = SSI_GetValue("TYPE_1");

if(ch==1)
{
document.getElementById("TYPE_2_graphical").disabled = 'true';
document.getElementById("TYPE_2_graphical").className ='checkbox';
document.getElementById("TYPE_2").disabled = 'true';
document.getElementById("TYPE_2_graphical").parentElement.parentElement.className = '';
}
</script>


the above script does not work. can u plz tell me the solution......
Your code will run once when the page loads and will not work, since TYPE_1 is not checked on page load. you need to assign an event listener to the first checkbox, so that when it is clicked your code above will run.

at the moment, I don't have time to try and get this one right, I suggest to search for "adding event listeners to checkboxes in javascript" or similar
Mr.Bahadir Ozkurt  this code is not running even at once.
plz find the solution......
Hi Gaurav,

I've come up with something to help you a little, but it does not work as I expected! Somehow the graphical checkboxes get clicked on page load (probably due to the used javascript library) and item 2 gets disabled without anyone clicking on item 1.


<script>
document.getElementById("TYPE_1_graphical").addEventListener('click', disabletwo() ,false);

function disabletwo ()
{
document.getElementById("TYPE_2_graphical").disabled = 'true';
document.getElementById("TYPE_2_graphical").className ='checkbox';
document.getElementById("TYPE_2").disabled = 'true';
document.getElementById("TYPE_2_graphical").parentElement.parentElement.className = '';
}
</script>


That's the best I can do given that I have work of my own to do as well :)
thanx for trying Mr. Bahadir Ozkurt ................but prob still remains..:)
...