Wednesday, 18 September 2013

dynamically change attribute id input jquery

dynamically change attribute id input jquery

Here I want to affect a value to dynamically attribute id of input here my
code jquery : for this code i can change to 0 the first value of input as
id=ouseval_0__SousEval_Note but i have many input with dinamic id
<script type="text/javascript">
$("#idselectdiv .tdLabelwidht").change(function () {
var idd = $(this).val();
alert(" selected value@ ="+idd);
if(idd=="-1"){
alert(" Veuillez selectionner un bon choix ");
}
if($(this).find("option:selected").text()!="Conforme"){
$("#souseval_5__SousEval_Note").val(0);
}
alert(" selected option- "+$(this).find("option:selected").text());
});
</script>
in my jsp i have a slect tag and the input who i want edite here value if
user select an option of select tag diferent of conforme:
<s:set name="n" value="0"/>
<s:iterator value="item" status="idStatus" >
<s:select
label="%{Item_Libelle}"
headerValue="---------------- Select ---------------"
headerKey="-1"
list="sousitem"
listKey="SousItem_ID"
listValue="SousItem_Libelle"
cssClass="tdLabelwidht"
id="selectedId"
name="%{'souseval['+#n+'].sousEvalItem.SousItem_ID'}"
/>
<s:textfield name="%{'souseval['+#n+'].SousEval_Note'}"
value="%{ponderation}"
placeholder="entrer Note"
/>
<s:set name="n" value="%{#n+1}"/>
</s:iterator>
equivalent code html :
<tr>
<td class="tdLabel"></td>
<td>
<input id="souseval_5__SousEval_Note" type="text" placeholder="entrer
Note" value="10" name="souseval[5].SousEval_Note">
</td>
</tr>

No comments:

Post a Comment