Toymods Car Club
www.toymods.org.au
F.A.Q. F.A.Q.    Register Register    Login Login    Home Home
Members Members    Search Search
Toymods » The Outhouse » Anyone know javascript?

Show: Today's Posts  :: Show Polls 
Email to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
AuthorTopic
Smokey228
Forums Junkie


Location:
Sydney
Registered:
January 2005
Anyone know javascript? Wed, 07 September 2005 06:47 Go to next message
i got this assignment, and i gotta link one site with another one. now atm, its all from the local hard drive. if i can work that out the rest should be simple.

my problem is, im trying to use a button to link the websites, but i cant seem to get the button to work.
this is wat i got so far.

<form action="www.google.com" method="get"
enctype="application/x-www-form-urlencoded&qu ot;>
<p><button type="button">Order form
</button></p>
</form>

have i missed sumfin, or not dun sumfin right? any help would be appreciated.

thanks, jason
  Send a private message to this user    
ehendrikd
Forums Junkie


Location:
ballarat
Registered:
April 2003
 
Re: Anyone know javascript? Wed, 07 September 2005 06:59 Go to previous messageGo to next message
Smokey228 wrote on Wed, 07 September 2005 16:47

i got this assignment, and i gotta link one site with another one. now atm, its all from the local hard drive. if i can work that out the rest should be simple.

my problem is, im trying to use a button to link the websites, but i cant seem to get the button to work.
this is wat i got so far.

<form action="www.google.com" method="get"
enctype="application/x-www-form-urlencoded&am p;qu ot;>
<p><button type="button">Order form
</button></p>
</form>

have i missed sumfin, or not dun sumfin right? any help would be appreciated.

thanks, jason



this isnt javascript, just html. i dont want to do your homework for your, but here is a clue:

look at this for your button
http://www.w3.org/TR/REC-html40/interact/forms.htm l#edef-INPUT
  Send a private message to this user    
Norbie
Forums Junkie


Location:
Brisbane
Registered:
May 2002
Re: Anyone know javascript? Wed, 07 September 2005 07:00 Go to previous messageGo to next message
Are you trying to navigate to a different site using a button? If so, you don't use a form. Something like this will do the trick:

<input type='button' onclick='javascript:window.location=http://www.goo gle.com/' value='Click here'>
  Send a private message to this user    
Shraka
Forums Junkie


Location:
Melbourne
Registered:
November 2003
Re: Anyone know javascript? Wed, 07 September 2005 07:04 Go to previous messageGo to next message
Norbie wrote on Wed, 07 September 2005 17:00

Are you trying to navigate to a different site using a button? If so, you don't use a form. Something like this will do the trick:

<input type='button' onclick='javascript:window.location=http://www.goo gle.com/' value='Click here'>


If you do it the above way, you don't need the form at all.

If you need the form to actualy submit some data, you can do it this way:

Quote:


<form action="www.google.com" method="get">
<input type="submit" value="Order form">
</form>



P.S. ehendrikd is right, this isn't javascript, it's just html. However Norbie's way does use javascript (as you can see).

[Updated on: Wed, 07 September 2005 07:06]

  Send a private message to this user    
Vee_469
Occasional Poster


Registered:
November 2004
Re: Anyone know javascript? Wed, 07 September 2005 14:42 Go to previous messageGo to next message
Norbie wrote on Wed, 07 September 2005 15:00

<input type='button' onclick='javascript:window.location=http://www.goo gle.com/' value='Click here'>



<input type='button' onclick='location=http://www.goo gle.com/' value='Click here'>


Should work too, no?

- Vee
  Send a private message to this user    
Norbie
Forums Junkie


Location:
Brisbane
Registered:
May 2002
Re: Anyone know javascript? Wed, 07 September 2005 23:52 Go to previous messageGo to next message
It might work on some browsers (if the "window" object is assumed to be the default), but it's less concise. For the sake of 7 characters I'd do it my way. Smile
  Send a private message to this user    
Shraka
Forums Junkie


Location:
Melbourne
Registered:
November 2003
Re: Anyone know javascript? Thu, 08 September 2005 00:57 Go to previous messageGo to next message
Norbie wrote on Thu, 08 September 2005 09:52

It might work on some browsers (if the "window" object is assumed to be the default), but it's less concise. For the sake of 7 characters I'd do it my way. Smile

For the sake of it working on browsers that don't have Java, i'd do it my way. Razz
  Send a private message to this user    
Norbie
Forums Junkie


Location:
Brisbane
Registered:
May 2002
Re: Anyone know javascript? Thu, 08 September 2005 01:44 Go to previous messageGo to next message
Who the hell uses browsers with no javascript support any more? I don't believe in designing sites to cater for 0.01% of the online population.
  Send a private message to this user    
MR. 2
Forums Junkie


Location:
Parramatta
Registered:
July 2002
Re: Anyone know javascript? Thu, 08 September 2005 02:03 Go to previous messageGo to next message
Quote:

For the sake of it working on browsers that don't have Java, i'd do it my way


java and javascript are different dont confuse them.
  Send a private message to this user    
Shraka
Forums Junkie


Location:
Melbourne
Registered:
November 2003
Re: Anyone know javascript? Thu, 08 September 2005 03:11 Go to previous messageGo to next message
MR. 2 wrote on Thu, 08 September 2005 12:03

Quote:

For the sake of it working on browsers that don't have Java, i'd do it my way


java and javascript are different dont confuse them.

Programing scum. Razz

And Norby, I design stuff that doesn't work in anything but the latest version of IE, so I see your point. If someone wants to see my page, they can bloodywell use whatever I design the page for. Cool Laughing
  Send a private message to this user    
Vee_469
Occasional Poster


Registered:
November 2004
Re: Anyone know javascript? Thu, 08 September 2005 04:47 Go to previous messageGo to next message
Norbie wrote on Thu, 08 September 2005 07:52

It might work on some browsers (if the "window" object is assumed to be the default), but it's less concise. For the sake of 7 characters I'd do it my way. Smile


Good point

- Vee
  Send a private message to this user    
Mx73_LuXoBarge
Regular


Location:
Bris-vague-us
Registered:
October 2002
Re: Anyone know javascript? Thu, 08 September 2005 10:48 Go to previous messageGo to next message
I realise that this is not the place for such discussion (nor such a question...anyhoo), but there is a fundemental flaw in every option put forth...

Forms are not for navigation, ever. This is one of the key principles laid down in Tim Berners Lee's orignal design for the 'world wide web', written in 1982.
First of all, here's the answer to the original request:
 
<a href="fileName.html" title="Go to next page">Clickity click!</a>


If you want it to look like a button, try this: (google 'CSS buttons' for more)
 
<a href="fileName.html" style="border:2px outset #ccc;padding:3px 2px; background:#aaa; color:#000;">Clickity click!</a>


As for the forms (<form>) vs. links (<a>) thing, the reason is quite simple. Forms are designed to accept and relay information entered by a person. Links are designed to be the sole navigation mechanism of the world wide web and as such, the web has been designed around the above premise. All 'bots' (computer controlled browsers) use links to navigate between pages. This is very important as without search bots indexing your site, it will never show up on Google, Yahoo or any of the search sites. Whilst having people link to your site will get the home page listed with search engines, if they're unable to scan deeper you will be given a VERY low search rank due to lack of content.

There are many more reasons, but I think that'll do considering this is a automotive forum Razz

Shraka


I design stuff that doesn't work in anything but the latest version of IE, so I see your point.


Do you actually get paid for purposely excluding customers from your clients' sites?
Sorry, I just can't stand such an ignorant attitude Sad

[Updated on: Thu, 08 September 2005 10:51]

  Send a private message to this user    
Norbie
Forums Junkie


Location:
Brisbane
Registered:
May 2002
Re: Anyone know javascript? Thu, 08 September 2005 13:44 Go to previous messageGo to next message
I understand what you're saying and I agree, but your solution doesn't answer the question which was asked.

Smokey228 wrote on Wed, 07 September 2005 16:47

my problem is, im trying to use a button to link the websites, but i cant seem to get the button to work.

He wanted a button - not a link, and not a link that looks like a button, but an actual button. Smile
  Send a private message to this user    
thechuckster
Forums Junkie


Location:
Brisbane
Registered:
February 2003
 
Re: Anyone know javascript? Thu, 08 September 2005 14:24 Go to previous messageGo to next message
why not do what this forum does?

like the buttons to send a PM or an email to the person posting a message? an image that looks like button (e.g.)
<a href=URL><img alt=description src=URL border=0></a>


ok ... so it cheats (because it's not a real form element) but it works - and you can be a lazy web developer (like Shraka) yet still make codes that works in any web browser not just iExploder.
  Send a private message to this user    
thu187
Forums Junkie


Location:
Sydney
Registered:
September 2004
Re: Anyone know javascript? Thu, 08 September 2005 16:12 Go to previous messageGo to next message
thechuckster wrote on Fri, 09 September 2005 00:24

why not do what this forum does?

like the buttons to send a PM or an email to the person posting a message? an image that looks like button (e.g.)
<a href=URL><img alt=description src=URL border=0></a>




Because buttons are built into windows thus you do not have to download them thus the site will load quicker.


  Send a private message to this user    
Mx73_LuXoBarge
Regular


Location:
Bris-vague-us
Registered:
October 2002
Re: Anyone know javascript? Thu, 08 September 2005 22:32 Go to previous messageGo to next message
Norbie wrote on Thu, 08 September 2005 23:44

I
He wanted a button - not a link, and not a link that looks like a button, but an actual button. Smile


He wanted a button, but his assignment is to link two web pages. His interpretation of the task at hand was incorrect, hence why I felt the need to set the record straight before another person starting adding garbage code to the web Wink


Ok, you want a form that links to another page? sure...
<?php
if(isset($_POST['target'])) 
    header('Location:'.$_POST['target']);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd&q uot;>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="en-au">
<title>Google Page Jump</title>
<script type="text/javascript">
function pageJump(id) {
	var form, targURL;
	form = document.getElementById(id);
	targURL = form.getElementsByTagName('input')[0].value;
	window.location = targURL;
	return false;
}
</script>
<style type="text/css"
</head>
<body>
	<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" id="pJump" onsubmit="return pageJump('pJump');" >
		<fieldset>
			<legend>Google Jump</legend>
			<input type="hidden" name="target" value="http://google.com/">
			<input type="submit" value="Go to Google">
		</fieldset>
	</form>
</body>
</html>


That page requires a PHP server to function correctly, but it will work in every browser ever made. Change the input type="hidden" to type="text" and suddenly the user can enter in the address they want to visit. Hoorah. Neutral

Norbie: Event handlers do not require the javascript: protocol. In fact, the javascript: protocol was never part of a formal standard and as such is merely a "hack that still works".
You should be attaching events using DOM2 methods. Have a search on 'unobtrusive scripting' if you want more details Smile
  Send a private message to this user    
Mx73_LuXoBarge
Regular


Location:
Bris-vague-us
Registered:
October 2002
Re: Anyone know javascript? Thu, 08 September 2005 23:07 Go to previous message
thu187 wrote on Fri, 09 September 2005 02:12


Because buttons are built into windows thus you do not have to download them thus the site will load quicker.


Correct. More importantly, different browsers and different OS's have very different native form controls (eg: glass buttons on OSX Safari). Each user is accustomed to the default display of form elements on their browser and are subconsiously tuned into recognising them.

Following established visual and interaction conventions is the single most important aspect of user interface design. That is why we try to use standard form controls instead of javascript powered images and real links instead of javascript powered forms. It's not because javascript is bad (it's not, when used responsibly), it's because the user has preconcieved (and CORRECT) nnnotions of what action that element should cause.

If any of you guys want to go into more detail about this stuff, I'm a staff member @ codingforums.com and I'm also a core member of the Web Standards Group (http://webstandardsgroup.org) -- an international group started in Australia with meetings in Bris, Sydney, Melbourne, Perth and Wellington.
If you're looking for specific help with web stuff, PM me at codingforums with your question and I'll help you out Smile
(just make sure to mention you're from toymods Wink)


cheers,
Andrew.

[Updated on: Thu, 08 September 2005 23:14]

  Send a private message to this user    
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic:avatar
Next Topic:go outside and look at the moon right now!
Goto Forum:
-=] Back to Top [=-

Current Time: Thu Mar 28 12:47:24 UTC 2024

Total time taken to generate the page: 0.006321907043457 seconds

Bandwidth utilization bar

.:: Contact :: Home ::.

Powered by: FUDforum 2.3.8
Copyright ©2001-2003 Advanced Internet Designs Inc.