Entry
Drop down menu - how can I show an alert message with info and then redirect to URL if yes.
Mar 27th, 2005 01:14
Andrew D, Linda Turner,
Some thing like this should do it.
<script language=javascript>
// <!--
function showselect(){
// value is the value inside <option value=''>
a=document.f.sb.options[document.f.sb.selectedIndex].value ;
// text is the bit between > </option>
b=document.f.sb.options[document.f.sb.selectedIndex].text ;
if (a){
if (confirm('Are you sure you want '+ b + '?')){
location.href='http://some.domain.com/url.htm?value=' + a;
}
}
}
// -->
</script>
<form name=f>
<select name=sb onchange='javascript:showselect();'>
<option value=''>--- Select Option ---</option>
<option value='1'>option 1</option>
<option value='2'>option 2</option>
<option value='3'>option 3</option>
<option value='4'>option 4</option>
</select>
</form>
I hope that helps :)
Cheers
cya
Andrew