473,387 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Javacsript Button

Hi Guys,

I'm a total newbie trying to make a simple series of click buttons to load up different pages for a target frame on the low side of a page. Right now I'm still struggling with just the buttons. So far the HTML ideas I've tried have let me down so I've turned to Java and just found this script (I'll use Google as the example URL here):

[HTML]<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function goToURL() { window.location = "http://www.google.com "; }
// End -->
</script>
</HEAD>

<BODY>
<form>
<input type=button value="Go to Google" onClick="goToURL()">
</form>
</BODY>[/HTML]

... It works if I only want to redirect to a single page (ie. www.google.com by itself), but what I can't seem to do is modify that code so that I can create an second additional button (say to go to yahoo). I tried to modify it like this, but got nowhere:

function goToURL(1) { window.location = "http://www.google.com "; }
function goToURL(2) { window.location = "http://www.yahoo.com "; }

... Because my computer doesn't recognize "goToURL(1)" only "goToURL()"

I'd also like to know how I can modify a target URL...

(a) to load in a different frame below.

(b) to include a search string, like this one say for youtube:

"http://www.youtube.com/results?search_query=" + searchString;

... Any help greatly appreciated!

Thanks,
Parkpost
Nov 21 '07 #1
3 1918
chaarmann
785 Expert 512MB
Hi Guys,

I'm a total newbie trying to make a simple series of click buttons to load up different pages for a target frame on the low side of a page. Right now I'm still struggling with just the buttons. So far the HTML ideas I've tried have let me down so I've turned to Java and just found this script (I'll use Google as the example URL here):

<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function goToURL() { window.location = "http://www.google.com "; }
// End -->
</script>
</HEAD>

<BODY>
<form>
<input type=button value="Go to Google" onClick="goToURL()">
</form>
</BODY>

... It works if I only want to redirect to a single page (ie. www.google.com by itself), but what I can't seem to do is modify that code so that I can create an second additional button (say to go to yahoo). I tried to modify it like this, but got nowhere:

function goToURL(1) { window.location = "http://www.google.com "; }
function goToURL(2) { window.location = "http://www.yahoo.com "; }

... Because my computer doesn't recognize "goToURL(1)" only "goToURL()"

I'd also like to know how I can modify a target URL...

(a) to load in a different frame below.

(b) to include a search string, like this one say for youtube:

"http://www.youtube.com/results?search_query=" + searchString;

... Any help greatly appreciated!

Thanks,
Parkpost
You should post that in a javascript forum, not in a java forum.
Anyway, wih a slight modification, your program would work:
Expand|Select|Wrap|Line Numbers
  1. <HEAD>
  2. <SCRIPT LANGUAGE="JavaScript">
  3. <!-- Begin
  4. function goToURL1() { window.location = "http://www.google.com "; };
  5. function goToURL2() { window.location = "http://www.yahoo.com "; };
  6. //  End -->
  7. </script>
  8. </HEAD>
  9.  
  10. <BODY>
  11. <form>
  12. <input type=button value="Go to Google" onClick="goToURL1()">
  13. <input type=button value="Go to Yahoo" onClick="goToURL2()">
  14. </form>
  15. </BODY>
Nov 21 '07 #2
You should post that in a javascript forum, not in a java forum.
Anyway, wih a slight modification, your program would work:
Expand|Select|Wrap|Line Numbers
  1. <HEAD>
  2. <SCRIPT LANGUAGE="JavaScript">
  3. <!-- Begin
  4. function goToURL1() { window.location = "http://www.google.com "; };
  5. function goToURL2() { window.location = "http://www.yahoo.com "; };
  6. //  End -->
  7. </script>
  8. </HEAD>
  9.  
  10. <BODY>
  11. <form>
  12. <input type=button value="Go to Google" onClick="goToURL1()">
  13. <input type=button value="Go to Yahoo" onClick="goToURL2()">
  14. </form>
  15. </BODY>

Hi there,

This might help.


[HTML]
<html>
<body>

<form name=myform type=post action="http://www.google.com">

<input type='submit' value='Open Google webpage' onclick="this.form.target='_blank';return true;">
<input type='submit' value='Open Yahoo webpage' onclick="myform.action='http://www.yahoo.com'; return true;">

</form>

</body>
</html>
[/HTML]
Nov 21 '07 #3
Sorry for postig to the wrong forum. Thanks for the advice - we have progress!

Parkpost
Nov 21 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Matt | last post by:
I want to understand the difference between submit button and regular button: <input type="submit"> and <input type="button">. My understanding is that submit button will send the entire HTML form...
6
by: Skip Hollowell | last post by:
I am working on a menu bar for a site, and am using buttons in the bar (because the customer wants to use accessKeys for each selection, apparently it is too much work to click on them with a...
5
by: TrvlOrm | last post by:
Can any one please help me...I am new to JavaScript and I have been struggling with this code for days now and can't figure it out. I would like to get the Buttons to correspond with the action...
7
by: Yaqian Fang | last post by:
Hi, could anyone please tell me how to make a button look like "being clicked"? A button picture always looks static, though a link is associated with it. Thank you.
25
by: KK | last post by:
Hi, I am using history.go(-1) for implementing the back button functionality. Its working fine but with this exception. 1. The page which is having back button has some hyperlinks on it. ...
3
by: Zürcher See | last post by:
Someone has implemented a Datagrid Button for the Windows.Form?
18
by: jrhoads23 | last post by:
Hello, I am trying to find a way to tell if an .NET windows forms Button (System.Windows.Forms.Button) is "depressed" (pushed down). For my application, I can not use a check box control set to...
18
by: Colin McGuire | last post by:
Hi - this was posted last weekend and unfortunately not resolved. The solutions that were posted almost worked but after another 5 days of working on the code everynight, I am not further ahead....
7
by: =?Utf-8?B?bWFydGluMQ==?= | last post by:
Hi, All, I create button in the code ( Dim Button as new Button), not using button web component (means not drap button and drop it ont he webform), after that I try to use button_click event,...
23
by: shashi shekhar singh | last post by:
Dear sir, I have a word document file contains text and images, now i have saved it as a web page and wants to display it on browser , using , string str=directory.getfiles("");...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.