Jump to content

[SOLVED] Regex & Select Boxes


Wolphie

Recommended Posts

I'm having trouble with the following snippet of code, i'm pretty certain it's to do with the regex strings.

 

The javascript:

<script language="javascript">
function checkColor() {
var selectBox = document.getElementById('effects');
var user_input = selectBox.options[selectBox.selectedIndex].value;
var str = user_input;

if((str.match(/color/i)) || (str.match(/all/i))) {
	document.getElementById('divColor').style.display = 'block';
} else {
	document.getElementById('divColor').style.display = 'none';
}
}
</script>

 

The Select Box:

<select id="effects" name="effects" style="width: 147px;" onchange="return checkColor();">
     <option value="1">Standard ($1.00)</option>
     <option value="2">Bold ($1.25)</option>
     <option value="3">Color ($1.25)</option>
     <option value="4">Underlined ($1.25)</option>
     <option value="5">Bold & Colored ($1.50)</option>
     <option value="6">Underlined & Colored ($1.50)</option>
     <option value="7">Bold & Underlined ($1.50)</option>
     <option value="8">All ($1.75)</option>
</select>

Link to comment
https://forums.phpfreaks.com/topic/89981-solved-regex-select-boxes/
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.