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
https://forums.phpfreaks.com/topic/78748-new-option/#findComment-398545
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
https://forums.phpfreaks.com/topic/78748-new-option/#findComment-398553
Share on other sites

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.