Log in

View Full Version : html form drop down issue



Jon101
01-04-2008, 06:40 PM
How would u make a html drop down list link to a web site? i linked it up how i hought it would work.. but no luck..




<select name="Categories" id="Categories" style="width:220px"">
<option value="http://www.google.com">testing</option>




any ideas?

boogyman
01-04-2008, 06:55 PM
in what capacity do you need the website?
... do you want to go to said site?
...... navigate in current browser window? popup window? iframe?
...... navigate to site on selection or on a button click?
... do you want to store the site?
...... store in database?
...... store in variable?


The method below I will show you how to navigate to the site by making a popup window when the option is selected.



__DOC_TYPE__
<html>
<head>
<title>TITLE</title>

<script type="text/javascript">

function goTo(var url='')
{
if(isNull(url) || url == '') {alert("The URL is not valid, contact the system administrator");}
else {
window.open(url, 'popUpWin','menubar=1,toolbar=1,status=1,resizable=1,left=0,top=0').focus();
}
}
</script>
</head>
<body>

<form name="frm" action="void(0);">
<label>
Website:
<select name="categories" onchange="goTo(this.value);return false">
<option value="" selected="selected>&ndash; Select Website &ndash;</option>
<option value="http://www.dynamicdrive.com">Dynamic Drive</option>
<option value="http://www.google.com">Google</option>
<option value="http://www.yahoo.com">Yahoo</option>
</select>
</label>
</form>
</body>
</html>

Jon101
01-04-2008, 06:58 PM
Thanks!
Jon