Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have check box and Dropdown list in a loop

XML
<td><input type="checkbox" name="'chk#'@item.CountryDetails.CountryId" id="chk"  onclick="disable()"  /></td>

                                       <td><select id="DRP" name="'DRP#'@item.CountryDetails.CountryId"><option value="null">--Select time--</option>
                                       <option value="monthly">Monthly</option>
                                       <option value="yearly">Yearly</option>


now i want to make disable all dropdown box ,

it should active only when check box is checked
Posted

Please see this jsfiddle example with your requirement

http://jsfiddle.net/xjn3Q/63/[^]
 
Share this answer
 
Comments
murkalkiran 2-Sep-14 7:35am    
i have done this my check box and dropdown list are in loop,

till what have done is working for only 1st checkbox and 1st dropdownlist

not for 2nd 3rd and so on......
Gihan Liyanage 2-Sep-14 7:42am    
Can you please post the code with loop part. I cant understand what you saying,"In a loop"
murkalkiran 3-Sep-14 2:10am    
foreach (var item in Model.ExchangeRateCollection)
{

<tr>
<td>@item.CountryDetails.CountryName
</td>
<td>@item.CountryDetails.Currency.CurrencyCode.Trim()
</td>
<td>@item.CountryDetails.Currency.CurrencyType
</td>


@if (ui.RoleName.ToUpper() == "WS ADMIN")
{
<td>@item.ExchangeFactor
</td>
}
else
{
<td>

<span id="@item.CountryDetails.Currency.CurrencyCode.Trim()"></span>
<input class="input2 xfactor" size="20" style="width:110px !important;float:right" name="@item.CountryDetails.CountryId" id="@item.CountryDetails.CountryId" type="text" value="@item.ExchangeFactor" önblur="return validateExchangeFactor(this)"; />
</td>
}

<td>@item.CountryDetails.ShortCountryCode
</td>
<td>@item.CountryDetails.Currency.Symbol
</td>


@if (ui.RoleName.ToUpper() == "WS ADMIN")
{
<td class="last">
<span id="@item.CountryDetails.Currency.CurrencyCode.Trim()"></span>
<input class="input2 xfactor" style="width:160px !important" size="20" name="@item.CountryDetails.CountryId" id="@item.CountryDetails.CountryId" type="text" value="@item.CustomExchangeFactor" önblur="return validateExchangeFactor(this)"; />
</td>
}

<td><input type="checkbox" name="'chk#'@item.CountryDetails.CountryId" id="chk" önclick="Active()" /></td>

<td><select disabled="disabled" id="DRP" name="'DRP#'@item.CountryDetails.CountryId"> <option value="null" >--Select time--</option>
<option value="monthly">Monthly</option>
<option value="yearly">Yearly</option>
</select></td>
try like this

XML
<!DOCTYPE html>
<html>
<body>

<p>An unordered list:</p>
<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>
<input  id="myCheck" type="checkbox" value="0" />

<p id="Naveen">
<select>
   <option value="volvo">Volvo</option>
   <option value="saab">Saab</option>
   <option value="mercedes">Mercedes</option>
   <option value="audi">Audi</option>
</select>
<select>
   <option value="volvo1">Volvo1</option>
   <option value="saab1">Saab1</option>
   <option value="mercedes1">Mercedes1</option>
   <option value="audi1">Audi1</option>
</select>
<select>
   <option value="volvo2">Volvo2</option>
   <option value="saab2">Saab2</option>
   <option value="mercedes2">Mercedes2</option>
   <option value="audi2">Audi2</option>
</select>

</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {

var xc = document.getElementById("myCheck").checked
alert(xc);
if(xc==true){

    var x = document.getElementsByTagName("LI");

for (var i=0, max=x.length; i <=max; i++) {

alert("hi");
document.getElementById("Naveen").style.display='none'

}}
}
</script>

</body>
</html>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900