Question

I'm in need of some help. I'm trying to get these php echos to be set to a bold font upon checking the checkbox that comes after it, then going back to how they are if it is unchecked.

They're all indiviual cells on this table, and I thought of maybe assigning each cell an id for JS to manipulate on click.(I took out the onclick function and scrapped that JS a bit ago, sorry.)

I was hoping someone could help me think of a way to link the two and using only Javascript. Thanks in advance!

<tr class="bgTitanium30" align="right">       
   <td align="left">Option 1</td>    
     <td id="a"><?php echo number_format("$bedien3base",2,",",".");?></td>
   <td><input type="checkbox" name="bedien3b" id="optb5" value="bedien3b" align="center">
     <td id="b"><?php echo number_format("$bedien3plus",2,",",".");?></td>
    <td><input type="checkbox" name="bedien3p" id="optp5" value="bedien3p" align="center">
</tr>                                                 
<tr class="bgPremiumWhite" align="right">       
   <td align="left">Option2</td>
     <td id="c"><?php echo number_format("$defbase",2,",",".");?></td>
   <td><input type="checkbox" name="defb" id="optb6" value="defb" align="center">
     <td id="d"><?php echo number_format("$defplus",2,",",".");?></td>
   <td><input type="checkbox" name="defp" id="optp6" value="defp" align="center">
</tr>
Was it helpful?

Solution

http://jsfiddle.net/kgGLp/

<script type="text/javascript">
function makeBold(x){
    if(document.getElementById(x).style.fontWeight !== "bold"){
        document.getElementById(x).style.fontWeight="bold";
    }
    else{
        document.getElementById(x).style.fontWeight="normal";
    }
}
</script>
<table>
    <tr>
        <td id="a" style="cursor:pointer" onclick="makeBold('a')">Whatever</td>
    </tr>
</table>

in the table where it has "makeBold('a')" - That "a" needs to be the id of the row.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top