Jump to content

new option()


cha0sriderx

Recommended Posts

you can do this through javascript or css.

 

JavaScript Version:

 

<script language="javascript">
function changecolor(selection)
{
document.getElementById(selection).style.color="red";
}
window.onload=function() {
changecolor('select1');
}
</script>

<select id="select1">
<option value="text value">Text Here
</select>

 

or..........

 

<script language="javascript">
function changecolor()
{
document.getElementsByTagName('select')[0].style.color="red";
}
window.onload=function() {
changecolor();
}
</script>

<select>
<option value="text value">Text Here
</select>

 

CSS Version:

 

<style type="text/css">
SELECT {color:red}
</style>

<select>
<option value="text value">Text Here
</select>

 

Link to comment
Share on other sites

you could also do this:

 


<script language="javascript">
function changecolor()
{
var i="0";
var myselection = document.getElementsByTagName('select')[i].style.color='#FF0000';
for(i;i<myselection.length;i++)
{
  document.getElementsByTagName('select')[i].style.color='#FF0000';
}
}
// Load Event
window.onload=function() {
changecolor();
}
// Error Catching
window.onerror=function() {
return true;
}
</script>

<select>
<option value="text value">Text Here
<option value="text value">Text Here
<option value="text value">Text Here
</select>

<select>
<option value="text value">Text Here
<option value="text value">Text Here
<option value="text value">Text Here
</select>

<select>
<option value="text value">Text Here
<option value="text value">Text Here
<option value="text value">Text Here
</select>

 

this javascript version will let you have multiple select/combo boxes with out you having to set the array key for each select menu every time; as in the other javascript, that I created above, that was similar to this one.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.