PDA

View Full Version : Need help with a form


Ii Metal Il
03-31-2007, 06:55 AM
Hi, can someone help me with a javascript form that:

1. Uses a select (drop down menu) to choose a url
2. Uses a button to open that url in a non-resizeable new window

The second form:

1. A form to log into msn web messenger
2. a button on that form that does all of the following in one click: log into and launch msn web messenger, and close that window

thanks in advance, any help or reference is greatly appreciated.

coothead
03-31-2007, 07:34 AM
Hi there Ii Metal Il,

here is a solution for your first problem...
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">

</style>

<script type="text/javascript">
var df;
window.onload=function(){
df=document.forms[0];
df.onsubmit=function () {
return goThere();
}
}
function goThere() {
if(df[0].value=='') {
return false;
}
else {
df.action=df[0].value;
df.reset();
return true;
}
}
</script>

</head>
<body>

<form action="#">
<div>
<select>
<option value="">---sites---</option>
<option value="http://www.google.com/">google</option>
<option value="http://www.htmlforums.com/">htmlforums</option>
<option value="http://www.bbc.co.uk/">bbc</option>
</select>
<input type="submit"/>
</div>
</form>

</body>
</html>
I am not familiar with msn web messenger so cannot assist you with this. :o :o

Ii Metal Il
03-31-2007, 07:42 AM
Thank you very very much! Here is a link to msn web messenger if that helps at all: MSN Web Messenger (https://login.live.com/login.srf?lc=1033&id=45940&ru=http://webmessenger.msn.com/default.aspx?pop=true&tw=20&fs=1&kv=9&ct=1161221124&ems=1&kpp=3&ver=2.1.6000.1)

i also see that doesn't open in a new window, how can I make it do so? I'm very unexperienced with JavaScipt :(.

coothead
03-31-2007, 08:18 AM
Hi there Ii Metal Il,

this amended code will open the links in a new window.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">

</style>

<script type="text/javascript">
var df;
window.onload=function(){
df=document.forms[0];
df[1].onclick=goThere
}

function goThere() {
if(df[0].value=='') {
return;
}
else {
window.open(df[0].value);
df.reset();
return true;
}
}
</script>

</head>
<body>

<form action="#">
<div>
<select>
<option value="">---sites---</option>
<option value="http://www.google.com/">google</option>
<option value="http://www.htmlforums.com/">htmlforums</option>
<option value="http://www.bbc.co.uk/">bbc</option>
</select>
<input type="button" value="go there"/>
</div>
</form>

</body>
</html>

As I have no intention of downloading msn web messenger it is not possible for me to test for a logged in state. ;)