2011-01-15 9 views
0

4つの列を持つhtmlフォーム最初の2つの列は、入力ボックス内のサイズで、disabled = 'disabled'、ラジオボタンをクリックしてサイズを選択すると、チェックボックスが表示されます。彼らは、入力ボックスクリックチェックボックスセット入力attr

<table width="388" border="1" id="product1"> 
<tr> 
<td width="100">Width</td> 
<td width="100">Height</td> 
<td width="48">Price</td> 
<td width="65">Select</td> 
</tr> 
<tr> 
<td><input type="text" disabled='disabled'value="200"/><span> CMS</span></td> 
<td><input disabled='disabled'type="text" value="500"/><span> CMS</span></td> 
<td>£50.00</td> 
<td><input type="radio" name="product1" value="size1" /> Customise<input  type="checkbox" name="custom[size1]" class="custombox" value="1"/></td> 
</tr> 
<tr> 
<td>200</td> 
<td>1000</td> 
<td>£100.00</td> 
<td><input type="radio" name="product1" value="size2" /> Customise<input   disabled='disabled' type="checkbox" name="custom[size2]" class="custombox" value="1"/></td> 
</tr> 
<tr> 
<td>200</td> 
<td>1500</td> 
<td>£150</td> 
<td><input type="radio" name="product1" value="size3" /> Customise<input  type="checkbox" name="custom[size3]" class="custombox" value="1"/></td> 
</tr> 
</table> 
<table width="288" border="1" id="product2"> 
<tr> 
<td width="72">Width</td> 
<td width="75">Height</td> 
<td width="48">Price</td> 
<td width="65">&nbsp;</td> 
</tr> 
<tr> 
<td>200</td> 
<td>500</td> 
<td>£50.00</td> 
<td><input type="radio" name="product2" value="size1" /> Customise<input  type="checkbox" name="custom[size1]" class="custombox" value="1"/></td> 
</tr> 
<tr> 
<td>200</td> 
<td>1000</td> 
<td>£100.00</td> 
<td><input type="radio" name="product2" value="size2" /> Customise<input  type="checkbox" name="custom[size2]" class="custombox" value="1"/></td> 
</tr> 
<tr> 
<td>200</td> 
<td>1500</td> 
<td>£150</td> 
<td><input type="radio" name="product2" value="size3" /> Customise<input type="checkbox" name="custom[size3]" class="custombox" value="1"/></td> 
</tr> 
<table> 

CSS

input[type=checkbox] { 
display: none; 
} 

input[type=checkbox].shown { 
display: inline; 
} 

input .edit{ 
border:1px solid red; 
} 
input[disabled='disabled'] { 
border:0px; 
width:60px; 
padding:5px; 
float:left; 
background:#fff; 
} 

span{float:left; width:30px; padding:5px;} 

のjQueryを編集できるようにするために、そのテーブルの行の入力のクラスと無効のattrを変更したいです

これは私が考えたものであるが、その任意の助けを事前に

$("#product1 :checkbox").click(function(){ 
$(this).parent("tr").children("td :input").attr('disabled',''); 
$(this).parent("tr").children("td :input").toggleClass(edit); 
}); 

$("#product2 :checkbox").click(function(){ 
$(this).parent("tr").children("td :input").attr('disabled',''); 
$(this).parent("tr").children("td :input").toggleClass(edit); 
}); 

おかげで動作していません。

答えて

0

簡体質問はここset attr of inputs on this row場合は他の誰がこの問題

+0

誰かがこの問題を抱えている場合のための簡単な質問はこちらhttp://stackoverflow.com/questions/4701604/set-attr-of-inputs-on-thisrowrow –

0

jQuery's FAQによると、あなたはそれがあいまいなことができるので、あなたの.parent("tr")は、おそらく最高のアイデアではないですが、注意してください

$('#x').attr('disabled', false); 
//or 
$("#x").removeAttr('disabled'); 

を使用することができます。もっと具体的にする(クラスや何かを与える)。その答えと

+0

はこれを試していているが、そのは、$(この).parent()子ども(「編:入力」)動作していない。。のattr( '無効'、false);私はjqueryの完全な初心者ですので、親()と子()の仕組みを理解できません –

+0

あなたの簡潔な質問を見ました。 jQueryの例とドキュメントを見てください。あなたがそれと時間を費やすなら、すぐにそれを理解するでしょう。 – jcuenod