...

View Full Version : Help With Linking Forms



Jolin
10-21-2003, 01:02 AM
have this form-type link which looks like this:


<div style="filter: alpha (opacity=65, style=0);">
<br><br>
<div class="links">
<form name="jump">
<select style="border:3px solid #000000; font-size: 8pt; color: #666666; font-family: verdana; word-spacing: 0; text-align: center; line-height: 100%; text-indent: 0; margin: 0; padding: 0; background: #000000" onchange="self.location=this.options[this.selectedIndex].value" name="select">
<option selected>link</option>
<option value="http://www.home.com">home</option>
<option value="http://www.com">link</option>
<option value="http://www.com">link</option>
<option value="http://www.com">link</option>
<option value="http://www.com">link</option>
</select>
</form>


Is there anything i could do to make the "home" link stay in my iFrame and the "link" links open in a new window? As in if i select the option "home" i would be nevigated back home inside my iFrame while if i select one of my friends links which is "link", it would pop up in a new window.

Is there anything i could do keeping the same form-type?

Thanks!

-Jolin

glenngv
10-21-2003, 11:15 AM
function go(sel){
var index = sel.selectedIndex;
if (sel.options[index].value!='') {
if (index == 1) location.href = sel.options[index].value; //home
else window.open(sel.options[index].value); //other links
}
}
...
<select onchange="go(this)">

Jolin
10-21-2003, 11:40 AM
Thanks glenngv for coming to my aid.

However, where do i insert this javascript, after my form code?

Or if this javascript is inclusive of the form code, where do i add my hyperlinks in the code?

Thanks!

-Jolin

glenngv
10-21-2003, 11:50 AM
put the script inside the <head> tag
then in the form:
<form>
<select onchange="go(this)">
<option selected>--Select one--</option>
<option value="http://www.mydomain.com/home.htm">Home</option>
<option value="http://www.yahoo.com">Yahoo</option>
<option value="http://www.codingforums.com">CodingForums</option>
<option value="http://www.microsoft.com">Microsoft</option>
<option value="http://www.hotmail.com">Hotmail</option>
</select>
</form>

Jolin
10-21-2003, 02:00 PM
it doesnt work :confused:

my <head> looks something like this:

<html>
<head>
<title>title</title>
<style><!--body{cursor:crosshair}--></style>
<style>

function go(sel){
var index = sel.selectedIndex;
if (sel.options[index].value!='') {
if (index == 1) location.href = sel.options[index].value; //home
else window.open(sel.options[index].value); //other links
}
}
...
<select onchange="go(this)">

</head>


My <body> where my form is looks something like this:


<div style="width: 30px;position: absolute; top: -225px; left: 360px;">
<div style="filter: alpha (opacity=65, style=0);">
<br><br>
<div class="links">
<form name="jump">
<select style="border:3px solid #000000; font-size: 8pt; color: #666666; font-family: verdana; word-spacing: 0; text-align: center; line-height: 100%; text-indent: 0; margin: 0; padding: 0; background: #000000" onchange="self.location=this.options[this.selectedIndex].value" name="select">
<select onchange="go(this)">
<option selected>LINKS</option>
<option value="http://www.home.com">home</option>
<option value="http://friend.com">friend1</option>
<option value="http://friend.com">friend2</option>
<option value="http://friend.com">friend3</option>
<option value="http://friend.com">friend4</option>
</select>
</form>


Please correct me if there is any mistakes with this. Thanks again for your help. I really appreciated it.

-Jolin

glenngv
10-22-2003, 06:38 AM
I thought you already know HTML and javascript. You should put the javascript codes in the <script> tag. :rolleyes:

<html>
<head>
<title>title</title>
<style><!--body{cursor:crosshair}--></style>
<script type="text/javascript">

function go(sel){
var index = sel.selectedIndex;
if (sel.options[index].value!='') {
if (index == 1) location.href = sel.options[index].value; //home
else window.open(sel.options[index].value); //other links
}
}
</script>
</head>
<body>
<div style="width: 30px;position: absolute; top: -225px; left: 360px;">
<div style="filter: alpha (opacity=65, style=0);">
<br><br>
<div class="links">
<form name="jump">
<select style="border:3px solid #000000; font-size: 8pt; color: #666666; font-family: verdana; word-spacing: 0; text-align: center; line-height: 100%; text-indent: 0; margin: 0; padding: 0; background: #000000" onchange="go(this)" name="select">
<option selected>LINKS</option>
<option value="http://www.home.com">home</option>
<option value="http://friend.com">friend1</option>
<option value="http://friend.com">friend2</option>
<option value="http://friend.com">friend3</option>
<option value="http://friend.com">friend4</option>
</select>
</form>
</body>
</html>

Jolin
10-22-2003, 07:06 AM
oh hehe. totally forgotten about that :D

Thanks Glenn!!!:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum