Jump to content

change onclick buttons to onchange from a select


tryingtolearn

Recommended Posts

I am trying to be able to change the font-size and font of text in  a div

 

 

Right now I am using individual buttons for each like this (This works but...)

 

<script type="text/javascript"> 
  function fs(n)  { 
    document.getElementById('C').style.fontSize = n 
  } 
  function fn(n)  { 
    document.getElementById('C').style.fontFamily = n 
  } 
  
  </script> 
  <div style="font-family: arial, helvetica, sans-serif; color: #336699;" id="C">Text</div> 
  
  <input type="button" onClick="fs('12px')" value="12px"> 
  <input type="button" onClick="fs('14px')" value="14px"> 
  <input type="button" onClick="fs('18px')" value="18px"> 
  <input type="button" onClick="fs('24px')" value="24px"> 
  <input type="button" onClick="fs('36px')" value="36px"> 
  <input type="button" onClick="fs('48px')" value="48px"> 
  <input type="button" onClick="fs('60px')" value="60px"> 
  <input type="button" onClick="fs('72px')" value="72px">
  
  <input type="button" onClick="fn('arial')" value="arial"> 
  <input type="button" onClick="fn('tahoma')" value="tahoma"> 
  <input type="button" onClick="fn('times new roman')" value="times new roman"> 
  

 

But Id rather use two dropdown boxes like

 

<select name="fontSize"">

<option value="12px">12px</option>
<option value="14px">14px</option>
<option value="22px">22px</option>
<option value="36px">36px</option>
<option value="72px">72px</option>
</select>

<select name="font"">

<option value="arial">arial</option>
<option value="tahoma">tahoma</option>

</select>

 

But I cant seem to figure that out

 

Any ideas on the direction I need to be going in?

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.