Wolphie Posted February 7, 2008 Share Posted February 7, 2008 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> Quote Link to comment Share on other sites More sharing options...
emehrkay Posted February 7, 2008 Share Posted February 7, 2008 im pretty sure that user_input is undefined or numeric...probably undefined. What you need to grab is the innerHTML of the option not the value. Quote Link to comment Share on other sites More sharing options...
Wolphie Posted February 7, 2008 Author Share Posted February 7, 2008 Ah i see where i went wrong now. Thanks for that Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.