<html>
<body>
<script language="Javascript" type="text/javascript">
function change1()
{
isIE = (document.all)?true:false; //IE 6
isNN6 = (document.getElementById)?true:false;
var s1;
var s2;
if (isIE) s1=document.all["licence_1"];
if (isNN6) s1=document.getElementById("license_1");
if (isIE) s2=document.all["license_2"];
if (isNN6) s2=document.getElementById("license_2");
s2.checked= false;
s1.checked = true;
if (isIE) d1=document.all["d1"];
if (isNN6) d1=document.getElementById("d1");
if (isIE) d2=document.all["d2"];
if (isNN6) d2=document.getElementById("d2");
d1.style.backgroundColor="lightblue";
d2.style.backgroundColor="white";
}
function change2()
{
isIE = (document.all)?true:false; //IE 6
isNN6 = (document.getElementById)?true:false;
var s1;
var s2;
var d1, d2;
if (isIE) s1=document.all["licence_1"];
if (isNN6) s1=document.getElementById("license_1");
if (isIE) s2=document.all["license_2"];
if (isNN6) s2=document.getElementById("license_2");
s2.checked= true;
s1.checked = false;
if (isIE) d1=document.all["d1"];
if (isNN6) d1=document.getElementById("d1");
if (isIE) d2=document.all["d2"];
if (isNN6) d2=document.getElementById("d2");
d1.style.backgroundColor="white";
d2.style.backgroundColor="lightblue";
}
</script>
<table cellspacing="0" style="width:100%;">
<tr height="45">
<td style="width:20%;" class="ligne_tableau1"><input type="radio" name="license_1" id="license_1" value="license_1_65" checked="checked" onclick="change1();"><b>Site license</b></td>
<td style="width:65%;" class="ligne_tableau1">File can be shared by unlimited users within one corporate location (e.g. a regional office)</td>
<td style="width:5%;" class="ligne_tableau1"></td>
<td name="d1" id="d1" style="width:10%;" class="ligne_tableau1"> 65 €</td>
</tr>
<tr class="puce_texte"><td style="width:100%;" colspan="4" class="ligne_tableau2"></td></tr>
<tr height="45">
<td class="ligne_tableau1"><input type="radio" name="license_2" id="license_2" value="license_2_130" onclick="change2();"><b>Global license</b></td>
<td class="ligne_tableau1">File can be shared globally by unlimited users within the purchasing corporation (e.g. all employees of a single company)</td>
<td style="width:5%;" class="ligne_tableau1"></td>
<td name="d2" id="d2" class="ligne_tableau1"> 130 ?</td>
</tr>
</table>
</body>
</html>
<span class="syntaxdefault"></span><span class="syntaxkeyword">$(</span><span class="syntaxstring">'input[name="license"]'</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">on</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'change'</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> function</span><span class="syntaxkeyword">()</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault"> var $tr </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">$(</span><span class="syntaxdefault">this</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">parents</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'tr'</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault"> $tr</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">parents</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'table'</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">find</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'td'</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">css</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'background'</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'#F2F3F3'</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault"> $tr</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">find</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'td:last-child'</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">css</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'background'</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'blue'</span><span class="syntaxkeyword">);<br />}); </span><span class="syntaxdefault"></span>
<span class="syntaxdefault">td</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">ligne_tableau1</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault"> background</span><span class="syntaxkeyword">:</span><span class="syntaxdefault"> blue</span><span class="syntaxkeyword">;<br />} </span><span class="syntaxdefault"></span>
<span class="syntaxdefault"></span><span class="syntaxkeyword">$(</span><span class="syntaxstring">'input[name="license"]'</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">on</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'change'</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> function</span><span class="syntaxkeyword">()</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault"> var $tr </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">$(</span><span class="syntaxdefault">this</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">parents</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'tr'</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault"> $tr</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">parents</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'table'</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">find</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'td'</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">removeClass</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'active'</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault"> $tr</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">find</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'td:last-child'</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">addClass</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'active'</span><span class="syntaxkeyword">);<br />}); </span><span class="syntaxdefault"></span>
Oui, mais ton code est bien plus beau ...spout a dit:Edit: grillé par MikeR
<html>
<body>
<script language="Javascript" type="text/javascript">
function clearAll(type)
{
var t;
var all = document.getElementsByTagName("input");
for (var i=0, max=all.length; i < max; i++) {
if (all[i].name.indexOf(type)>-1)
{
all[i].checked = false;
//alert("found "+all[i].name);
t=document.getElementById(all[i].name+'_v');
t.style.backgroundColor="white";
}
}
}
function change(d)
{
clearAll("license");
isIE = (document.all)?true:false; //IE 6
isNN6 = (document.getElementById)?true:false;
var t;
if (isIE) t=document.all[d+'_v'];
if (isNN6) t=document.getElementById(d+'_v');
t.style.backgroundColor="lightblue";
if (isIE) t=document.all[d];
if (isNN6) t=document.getElementById(d);
t.checked=true;
}
</script>
<table cellspacing="0" style="width:100%;">
<tr height="45">
<td style="width:20%;" class="ligne_tableau1"><input type="radio" name="license_1" id="license_1" value="license_1_65" checked="checked" onclick="change('license_1');"><b>Site license</b></td>
<td style="width:65%;" class="ligne_tableau1">File can be shared by unlimited users within one corporate location (e.g. a regional office)</td>
<td style="width:5%;" class="ligne_tableau1"></td>
<td name="license_1_v" id="license_1_v" style="width:10%;" class="ligne_tableau1"> 65 €</td>
</tr>
<tr class="puce_texte"><td style="width:100%;" colspan="4" class="ligne_tableau2"></td></tr>
<tr height="45">
<td class="ligne_tableau1"><input type="radio" name="license_2" id="license_2" value="license_2_130" onclick="change('license_2');"><b>Global license</b></td>
<td class="ligne_tableau1">File can be shared globally by unlimited users within the purchasing corporation (e.g. all employees of a single company)</td>
<td style="width:5%;" class="ligne_tableau1"></td>
<td name="license_2_v" id="license_2_v" class="ligne_tableau1"> 130 ?</td>
</tr>
</table>
</body>
</html>
<<html>
<body>
<script language="Javascript" type="text/javascript">
function clearAll(type)
{
var t;
var all = document.getElementsByTagName("input");
for (var i=0, max=all.length; i < max; i++) {
if (all[i].name.indexOf(type)>-1)
{
all[i].checked = false;
//alert("found "+all[i].name);
t=document.getElementById(all[i].name+'_v');
t.style.backgroundColor="white";
}
}
}
function change(d)
{
var s = d.split("_");
//alert(s[0]);
clearAll(s[0]);
isIE = (document.all)?true:false; //IE 6
isNN6 = (document.getElementById)?true:false;
var t;
if (isIE) t=document.all[d+'_v'];
if (isNN6) t=document.getElementById(d+'_v');
t.style.backgroundColor="lightblue";
if (isIE) t=document.all[d];
if (isNN6) t=document.getElementById(d);
t.checked=true;
}
</script>
<table cellspacing="0" style="width:100%;">
<tr height="45">
<td style="width:20%;" class="ligne_tableau1"><input type="radio" name="license_1" id="license_1" value="license_1_65" checked="checked" onclick="change('license_1');"><b>Site license</b></td>
<td style="width:65%;" class="ligne_tableau1">File can be shared by unlimited users within one corporate location (e.g. a regional office)</td>
<td style="width:5%;" class="ligne_tableau1"></td>
<td name="license_1_v" id="license_1_v" style="width:10%;" class="ligne_tableau1"> 65 €</td>
</tr>
<tr class="puce_texte"><td style="width:100%;" colspan="4" class="ligne_tableau2"></td></tr>
<tr height="45">
<td class="ligne_tableau1"><input type="radio" name="license_2" id="license_2" value="license_2_130" onclick="change('license_2');"><b>Global license</b></td>
<td class="ligne_tableau1">File can be shared globally by unlimited users within the purchasing corporation (e.g. all employees of a single company)</td>
<td style="width:5%;" class="ligne_tableau1"></td>
<td name="license_2_v" id="license_2_v" class="ligne_tableau1"> 130 ?</td>
</tr>
</table>
<br><br><br><br>
<table cellspacing="0" style="width:100%;">
<tr height="45">
<td style="width:20%;" class="ligne_tableau1"><input type="radio" name="maintenance_1" id="maintenance_1" value="maintenance_1_65" checked="checked" onclick="change('maintenance_1');"><b>Site maintenance</b></td>
<td style="width:65%;" class="ligne_tableau1">File can be shared by unlimited users within one corporate location (e.g. a regional office)</td>
<td style="width:5%;" class="ligne_tableau1"></td>
<td name="maintenance_1_v" id="maintenance_1_v" style="width:10%;" class="ligne_tableau1"> 65 €</td>
</tr>
<tr class="puce_texte"><td style="width:100%;" colspan="4" class="ligne_tableau2"></td></tr>
<tr height="45">
<td class="ligne_tableau1"><input type="radio" name="maintenance_2" id="maintenance_2" value="maintenance_2_130" onclick="change('maintenance_2');"><b>Global maintenance</b></td>
<td class="ligne_tableau1">File can be shared globally by unlimited users within the purchasing corporation (e.g. all employees of a single company)</td>
<td style="width:5%;" class="ligne_tableau1"></td>
<td name="maintenance_2_v" id="maintenance_2_v" class="ligne_tableau1"> 130 ?</td>
</tr>
</table>
</body>
</html>