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 » can anyone help me with some basic javascript?

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


Location:
Launceston, Tasmania
Registered:
May 2002
haha, funny little head!
can anyone help me with some basic javascript? Mon, 29 September 2003 23:49 Go to next message
I'm in the middle of a javascript assignment. it is only introducary level so it is quite basic. The bit i am stuck on is this:

We have to make a webpage for a shop. The user selects the goods that they want and then proceed to the checkout. The bit i am unsure on is how to get the the details of the goods selected to show up on the following html page.

If anyone can help me with this it would be greatly appreciated. Even a link to a webpage as an example would be great Smile
  Send a private message to this user    
ehendrikd
Forums Junkie


Location:
ballarat
Registered:
April 2003
 
Re: can anyone help me with some basic javascript? Tue, 30 September 2003 00:29 Go to previous messageGo to next message
your problem is that you variables are not perstant to the checkout page, ie. they disappear when you go to the checkout.

i have solved this problem a few times by making my site with frames. make the parent 'frameset' html page contain the persistant variables that you want to transfer from the purchasing part to the checkout part.

so in the purchacing part you say eg. 'parent.myVariable = 30.75', load the checkout page, then use this parent variable beacuse it will still be there.

cheers
evan
  Send a private message to this user    
Nark
Forums Junkie


Location:
Cabramatta, NSW
Registered:
May 2002
      Nark@toymods.net/Work
Re: can anyone help me with some basic javascript? Tue, 30 September 2003 01:47 Go to previous messageGo to next message
You can either store the values in cookies, or you can make each link a form post (a PITA).
  Send a private message to this user    
ehendrikd
Forums Junkie


Location:
ballarat
Registered:
April 2003
 
Re: can anyone help me with some basic javascript? Tue, 30 September 2003 03:10 Go to previous messageGo to next message
hi nark

if it is submitted via a form post, don't you need something to recive it on the server side? php, asp or cgi?

i think the assignment in question was a javascript one

good idea with the cookies though, i never thought of that

evan
  Send a private message to this user    
Nark
Forums Junkie


Location:
Cabramatta, NSW
Registered:
May 2002
      Nark@toymods.net/Work
Re: can anyone help me with some basic javascript? Tue, 30 September 2003 04:27 Go to previous messageGo to next message
No, if you submit it as a POST, then the variables are encoded into the URL, then you can use JavaScript to grab the values of the variables out.
  Send a private message to this user    
ehendrikd
Forums Junkie


Location:
ballarat
Registered:
April 2003
 
Re: can anyone help me with some basic javascript? Tue, 30 September 2003 04:52 Go to previous messageGo to next message
um sorry to be bastard, but that aint right dude

http://forums.devshed.com/t1172/s.html

and a little test case:

js_1.html:

<html>
<body>
<form action="js_2.html" method="POST">
<input name="data" type="text">
<input type="submit">
</form>
</body>
</html>

js_2.html:

<html>
<body onload="javascript:document.write(location.hr ef);">
</body>
</html>
  Send a private message to this user    
Nark
Forums Junkie


Location:
Cabramatta, NSW
Registered:
May 2002
      Nark@toymods.net/Work
Re: can anyone help me with some basic javascript? Tue, 30 September 2003 04:54 Go to previous messageGo to next message
Oops, it was a GET then. I never remember which one is which. Sad
  Send a private message to this user    
ehendrikd
Forums Junkie


Location:
ballarat
Registered:
April 2003
 
icon14.gif  Re: can anyone help me with some basic javascript? Tue, 30 September 2003 05:01 Go to previous messageGo to next message
ahh yes, i get mixed up between them too, i thought they were the other way around. Embarassed

the only thing you would have to do then is parse the location text, i might use this in future web sites

cheers Smile
  Send a private message to this user    
Nark
Forums Junkie


Location:
Cabramatta, NSW
Registered:
May 2002
      Nark@toymods.net/Work
Re: can anyone help me with some basic javascript? Tue, 30 September 2003 05:16 Go to previous messageGo to next message
From what I remember, you should just be able to refer the variables straight from JavaScript... All the parsing is done automatically...

Or am I mistaking it with PHP........ Might have to look it up....
  Send a private message to this user    
gtman
Forums Junkie


Location:
Perth
Registered:
November 2002
Re: can anyone help me with some basic javascript? Tue, 30 September 2003 06:44 Go to previous messageGo to next message
thats php, but for security reasons you should never do that anymore, but access through $_POST. But back to the original question, parent frames are the best way to do it in JS. I always found cookies to be a pita Smile
  Send a private message to this user    
cam_RA40
Forums Junkie


Location:
Launceston, Tasmania
Registered:
May 2002
haha, funny little head!
Re: can anyone help me with some basic javascript? Tue, 30 September 2003 07:03 Go to previous messageGo to next message
Thanks guys Smile i will have a go at the frames way tonight and see how i go. gtman, do you have any of your pages online that i could refer to?

thanks Smile
cam
  Send a private message to this user    
gtman
Forums Junkie


Location:
Perth
Registered:
November 2002
Re: can anyone help me with some basic javascript? Tue, 30 September 2003 08:40 Go to previous messageGo to next message
I don't really have any pages online that can are easily refferable. You looking for examples for said JS frame thingy?
  Send a private message to this user    
ashling
Regular


Location:
Baulkham Hills, Sydney
Registered:
February 2003
Re: can anyone help me with some basic javascript? Tue, 30 September 2003 09:41 Go to previous messageGo to next message
pass them through with a GET or append them to the URL yourself, and then borrow the following example Up To Something


1.html = 

<html>
<body>
<a href="2.html?var1=hi&matt=cool">l ink</a>
</body>
</html>

2.html =

<html>
<head>
<script language="JavaScript">

function doSomething()
{
	var args = parseQueryString();
	for (var arg in args)
	{
		alert(arg + ': ' + args[arg]);
	}
}

function parseQueryString ()
{
	str = location.search;
	var query = str.charAt(0) == '?' ? str.substring(1) : str;
	var args = new Object();
	if (query)
	{
		var fields = query.split('&');
		for (var f = 0; f < fields.length; f++)
		{
			var field = fields[f].split('=');
			args[unescape(field[0].replace(/\+/g, ' '))] = unescape(field[1].replace(/\+/g, ' '));
		}
	}
	return args;
}


</script>
</head>
<body onLoad="doSomething()">
</body>
</html>

  Send a private message to this user    
draven
Forums Junkie


I supported Toymods

Location:
Epping, Sydney
Registered:
May 2002
 
Re: can anyone help me with some basic javascript? Tue, 30 September 2003 09:44 Go to previous messageGo to next message
nerd Very Happy
  Send a private message to this user    
ashling
Regular


Location:
Baulkham Hills, Sydney
Registered:
February 2003
Re: can anyone help me with some basic javascript? Tue, 30 September 2003 09:50 Go to previous messageGo to next message
tis true, well... i'd cop geek with just a shrug.

besides, as a result of being a geek, i can drive a 6 speed twin turbo black mark IV surpa with 19 inch rims and a kick arse sound system at age 23 Very Happy

and own a house!



  Send a private message to this user    
draven
Forums Junkie


I supported Toymods

Location:
Epping, Sydney
Registered:
May 2002
 
Re: can anyone help me with some basic javascript? Tue, 30 September 2003 09:50 Go to previous messageGo to next message
show-off nerd Smile
  Send a private message to this user    
gtman
Forums Junkie


Location:
Perth
Registered:
November 2002
Re: can anyone help me with some basic javascript? Tue, 30 September 2003 10:01 Go to previous messageGo to next message
bastard Razz Smile

I wouldn't use parsing a GET string, I'd do the frame thing, less code, less messy, more sanity
  Send a private message to this user    
ashling
Regular


Location:
Baulkham Hills, Sydney
Registered:
February 2003
Re: can anyone help me with some basic javascript? Tue, 30 September 2003 12:41 Go to previous messageGo to next message
yep, probably easier Smile i hate frames though Razz

just offering options!
  Send a private message to this user    
gtman
Forums Junkie


Location:
Perth
Registered:
November 2002
Re: can anyone help me with some basic javascript? Tue, 30 September 2003 14:09 Go to previous messageGo to next message
Yeah, I'm not a big fan of frames either, tho iframes are much nicer, but for this application they are much more bearable then parsing huge urls. Then you would also have to generate huge href's as well to pass the information through, or make the href call a JS function to move between pages.... not my idea of fun Smile
  Send a private message to this user    
cam_RA40
Forums Junkie


Location:
Launceston, Tasmania
Registered:
May 2002
haha, funny little head!
Re: can anyone help me with some basic javascript? Tue, 30 September 2003 22:39 Go to previous messageGo to next message
I wanna be a nerd like ashling Razz what is your job dude? programmer?
  Send a private message to this user    
cam_RA40
Forums Junkie


Location:
Launceston, Tasmania
Registered:
May 2002
haha, funny little head!
Re: can anyone help me with some basic javascript? Tue, 30 September 2003 22:44 Go to previous messageGo to next message
thanks everyone! i ended up using ashling's (and nark's i think) method mainly because it fitted in to the page that i have already been working on. It didn't have frames to start off with so it was less muching around. Although the frames way seems to be an easier quicker way Wink
  Send a private message to this user    
Nark
Forums Junkie


Location:
Cabramatta, NSW
Registered:
May 2002
      Nark@toymods.net/Work
icon10.gif  Re: can anyone help me with some basic javascript? Tue, 30 September 2003 23:58 Go to previous messageGo to next message
cam_RA40 wrote on Wed, 01 October 2003 08:39

I wanna be a nerd like ashling Razz what is your job dude? programmer?


With a face like that, he can only be one thing...

P.I.M.P.
  Send a private message to this user    
ehendrikd
Forums Junkie


Location:
ballarat
Registered:
April 2003
 
Re: can anyone help me with some basic javascript? Wed, 01 October 2003 00:07 Go to previous messageGo to next message
Laughing
  Send a private message to this user    
ehendrikd
Forums Junkie


Location:
ballarat
Registered:
April 2003
 
Re: can anyone help me with some basic javascript? Wed, 01 October 2003 00:09 Go to previous messageGo to next message
but i agree with ashling, i hate frames, i only use them if i have to
  Send a private message to this user    
SupraPete
Forums Junkie


Location:
Sydney
Registered:
July 2002
   
Re: can anyone help me with some basic javascript? Wed, 01 October 2003 06:32 Go to previous messageGo to next message
Was leaving this thread for a while as I hate javascript, but theres something I hate more - frames. Mad

Frames are out. They've been out of the line-light for at least 3 or 4 years. Leave them alone.


Frames are evil. Mad EVIL! Mad



Now I'll go back to the 'quiet corner'.
  Send a private message to this user    
gtman
Forums Junkie


Location:
Perth
Registered:
November 2002
Re: can anyone help me with some basic javascript? Wed, 01 October 2003 06:35 Go to previous messageGo to next message
I think everyone agree's with that, but they are only used when desperately needed. The CMS I'm building will use frames for the admin section just so that stuff like navigation doesn't need to be reloaded, but don't blow your lid cause it'll be using iframes and div layers, not the normal, hell spawn framesets Smile
  Send a private message to this user    
SupraPete
Forums Junkie


Location:
Sydney
Registered:
July 2002
   
Re: can anyone help me with some basic javascript? Wed, 01 October 2003 06:39 Go to previous messageGo to next message
Hell even the weblogic Console uses frames Razz . At least 6.1 does, not sure about 8.1, we havn't gone there yet, and I couldn't be bothered playing with it, prefer games.
  Send a private message to this user    
Nark
Forums Junkie


Location:
Cabramatta, NSW
Registered:
May 2002
      Nark@toymods.net/Work
icon6.gif  Re: can anyone help me with some basic javascript? Wed, 01 October 2003 06:41 Go to previous messageGo to next message
HKSPete wrote on Wed, 01 October 2003 16:39

and I couldn't be bothered playing with it, prefer games.


Strange boy..... No No No
  Send a private message to this user    
SupraPete
Forums Junkie


Location:
Sydney
Registered:
July 2002
   
Re: can anyone help me with some basic javascript? Wed, 01 October 2003 06:50 Go to previous messageGo to next message
I was a contractor for 4 years. I'm simply not used to bringing work home. 5:30 comes around I turn the computer off and leave.
  Send a private message to this user    
SupraPete
Forums Junkie


Location:
Sydney
Registered:
July 2002
   
Re: can anyone help me with some basic javascript? Wed, 01 October 2003 06:51 Go to previous messageGo to next message
Oh and if you were being rude No No No
  Send a private message to this user    
Nark
Forums Junkie


Location:
Cabramatta, NSW
Registered:
May 2002
      Nark@toymods.net/Work
Re: can anyone help me with some basic javascript? Wed, 01 October 2003 06:57 Go to previous message
haha No, was joking...

It's Warcraft III night tonight! Can't wait to kick some arse. Very Happy
  Send a private message to this user    
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic:The Streets
Next Topic:XP Themes
Goto Forum:
-=] Back to Top [=-

Current Time: Fri Aug 1 07:13:48 UTC 2025

Total time taken to generate the page: 0.0059361457824707 seconds

Bandwidth utilization bar

.:: Contact :: Home ::.

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