Thanks for your code! I have changed it for my needs.
Can you tell me how can I reset all options to display="block" without knowing their ID? Both radio buttons has to reset the style of options before searching.
Code:
<script language="javascript" type="text/javascript">
function female()
{
var shirtselector=document.getElementById("shirtselector");
var fo=shirtselector.getElementsByTagName("option");
var l=fo.length;
var dele=[];
for (var i=0;i<l;i++)
{
if(fo[i].value.search(/f?rfi/i)<0) // here we search for a given string
{
dele.push(fo[i]);
}
else // if string is found inside option, we do this with the option:
{
fo[i].style.display = "none";
}
}
}
function male()
{
var shirtselector=document.getElementById("shirtselector");
var fo=shirtselector.getElementsByTagName("option");
var l=fo.length;
var dele=[];
for (var i=0;i<l;i++)
{
if(fo[i].value.search(/n?i/i)<0) // here we search for a given string
{
dele.push(fo[i]);
}
else // if string is found inside option, we do this with the option:
{
fo[i].style.display = "none";
}
}
}
</script>
Bookmarks