Domanda

I have a Sharepoint List with Radio-button field. If someone checks no then it should disable the ok button, but if yes is selected the ok button should be enabled. I need to write a javascript in CEWP to achieve this with no access to SPD, can some one please advise?

È stato utile?

Soluzione

<script type = "text/javascript">
function test_enable(id,id2)
/*parameter "id" should be id of "no" radiobutton and "id2" is of yes button 
*/
{
if(document.getElementById(id).checked==true)
{
document.getElementById(id2).enabled==false;
}
else
{
document.getElementById(id2).enabled==true;
}
}
</script>


<input type = "radio" id = "id" onchange = "test_enable('id','id2')" value = "No">

<input type = "button" id = "id2" onclick = "foo()" value = "click me!"> 

Simple!

Altri suggerimenti

You can do somehting like this

function show_hide(show, hide)
{
document.getElementById(show).style.display="block";
document.getElementById(hide).style.display="none";
}

<form method="post" action="aaa.php">
<input type="radio" name="search" value="standard" onClick="show_hide('standard', 'advanced')" checked />Standard Search
<div id="standard" style="display: block;">
Standard search div
</div>
<br />
<input type="radio" name="search" value="advanced" onClick="show_hide('advanced', 'standard')" />Advanced search
<div id="advanced" style="display: none;">
Advanced search div
</div>
<br />
<input type="submit" value="Submit" />
</form>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top