JavaScript and client side scripting.
Moderator: General Moderators
php12342005
Forum Commoner
Posts: 79 Joined: Mon Mar 21, 2005 3:35 am
Post
by php12342005 » Wed Apr 13, 2005 11:47 pm
Code: Select all
<html>
<head>
<script type="e;text/javascript"e;>
var mySel;
function getMultiple(ob)
{
if (ob.selectedIndex != -1)
{
mySel=ob.optionsїob.selectedIndex].value;
}
}
function DispPage()
{
confirm(mySel);
location.href=mySel.toString()
}
</script>
</head>
<body>
<form name='frmSelect'>
<select name='numbers' multiple='multiple' onblur='getMultiple(document.frmSelect.numbers);'>
<option value="e;http://www.sun.com/index.html"e;>Index</option>
<option value="e;http://www.sun.com/download/index.jsp"e;>Downloads</option>
</select>
<input type='submit' value='Go' onclick=DispPage();>
</form>
</body>
</html>
======================================
I hope users can go to selected sun's web-page (as new window) when they press button go .
could u help me to find errors?
thanks
Jcart | Please use
Smackie
Forum Contributor
Posts: 302 Joined: Sat Jan 29, 2005 2:33 pm
Post
by Smackie » Thu Apr 14, 2005 1:23 am
First off why are you posting a html/javascript in a php help form?? and second of all is there any error that pop up??
n00b Saibot
DevNet Resident
Posts: 1452 Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:
Post
by n00b Saibot » Thu Apr 14, 2005 2:04 am
Working code (edited to help you & suit me
)
Code: Select all
<html>
<head>
<script type="e;text/javascript"e;>
var mySel;
function getMultiple(ob)
{
if (ob.selectedIndex != -1)
mySel=ob.optionsїob.selectedIndex].value;
}
function DispPage()
{
confirm(mySel);
location.href=mySel.toString();
}
</script>
</head>
<body>
<form name='frmSelect' action="e;javascript:DispPage()"e;>
<select name='numbers' multiple='multiple' onblur='getMultiple(this)'>
<option value="e;http://www.sun.com/index.html"e;>Index</option>
<option value="e;http://www.sun.com/download/index.jsp"e;>Downloads</option>
</select>
<input type='submit' value='Go'>
</form>
</body>
</html>
php12342005
Forum Commoner
Posts: 79 Joined: Mon Mar 21, 2005 3:35 am
Post
by php12342005 » Thu Apr 14, 2005 3:46 am
Hi Saibot,
it works well.
(but) do u know how to pop up selected link to a new window? similar to HTML TAG target="_new"?
thanks.
n00b Saibot
DevNet Resident
Posts: 1452 Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:
Post
by n00b Saibot » Thu Apr 14, 2005 4:02 am
php12342005 wrote: (but) do you know how to pop up selected link to a new window? similar to HTML TAG target="_new"?
Why don't you use target='_new'. Do you want the confirmation in anew window or the page to open in a new window
Could you explain this a bit further please.
php12342005
Forum Commoner
Posts: 79 Joined: Mon Mar 21, 2005 3:35 am
Post
by php12342005 » Thu Apr 14, 2005 4:19 am
yes.
when i click button "Go", the selected page (Sun's link) replaces current page in same window - i hope selected page is in a new window (current page is still there).
how to use 'target="_new" in javascript? i tried but it didn't work.
n00b Saibot
DevNet Resident
Posts: 1452 Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:
Post
by n00b Saibot » Thu Apr 14, 2005 4:26 am
OK for that you have to use the window.open method.
Code: Select all
function DispPage()
{
confirm(mySel); //I dont know why it is here...
window.open(mySel.toString());
}
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Thu Apr 14, 2005 4:29 am
Moved to client side