top left endcap spacer
spacerWelcome to the GU Forums
THE TWO MORE MINUTES NETWORK: GUComics | GUForums | GUGaming | ItsaKon | Raptor Guts
spacer
flagspacer
HomespacerComicspacerArchivesspacerForumsspacerStorespacer
top right endcap

Go Back   Main Forums > GU Comics > Tech Forum

Reply
JavaScript help needed
Thread Tools
Old 07-21-2010
spacer
drgnmstr44 drgnmstr44 is offline
aka Mike Garhart
 
Join Date: Sep 2004
Fwang: 542"

Location: York, PA
Send a message via MSN to drgnmstr44
JavaScript help needed

So I was trying to avoid this but I don't think it's going to work out well with out poking you other techies and getting some help from people that use it in a regular basis. The situation is this: I'm currently enrolled in a Programming with JavaScript course at my university and the class is rather bad. My background is in Java Programming and using web front .jsp and .jspx to display things to a user and get information from a user. Some of my projects for work actually use JS and I know enough to get by with it. My current situation though see me getting frustrated, angry, and yelling at my computer screen because I can't get any of this to work over the past 2 weeks and my so called instructor isn't very helpful.

Last week's assignment was to create a web page and use java script to print a line in that web page to greet a user with the appropriate greeting of the day; good morning, good afternoon, good evening. this is based on the return value of getHours() method of the date object. I was able to write the js to to do this in an alert box with a series of if statments but it needed to write to the page. I placed at the top of the page a <span id='greeting'> tag set and used document.getElementById('greeting'); to grab that tag. however I couldn't figure out how to actually write "<h1>Good Morning</h1>" to the screen in that tag. I tried document.write() but that didn't work. I asked my instructor but he didn't help at all. eventually I removed the span tag and replaced it with a script tag to call the writing function when loaded and use document.write() to actually print what I wanted. In side the script tag I made a method call to the greeting function i had writen in my .js file. this worked but didn't do want I thought it should and I never learned how to actually write things from a separate scripting file into a HTML document with out including a <script> tag set, which my class book frowns upon.

This week, I'm supposed to create and order form for pizzas. it take in name, phone, full address and a quantity of pizzas to order. it has two buttons on it; one resets the form while the other calls a JavaScript function. in this function, I'm supposed to create a new window where the order will be confirmed. In the new window, I am to write "You are placing an order for x number of pizzas. you will receive a call soon at the phone number xxx-xxxx." Where x is supposed to be the value retrieved from the quantity text box and xxx-xxxx is the value retrieved from the phone text box.

I know that in the original window I can do this: var phone = document.getElementById('phone'); to get the input text box object. from here I believe that if I do alert(phone.value); I would get a pop-up displaying the value entered in the form. This works. my problem here was I couldn't figure out how to access the variable phone that I created, which had a global scope in that window, or access the text box inputs in the original window from the pop-up window. I submitted for help to my instructor who completely ignored what I was asking for and told me i had a spelling error, which was true. I correct that and sent the same request to help back to get told that:

Quote:
Many firefox and mozzila plug in have a JavaScript debugger in them. you can also use alert(); to debug your code as well.
this leave me to a "thanks for nothing, chuckle-head. why are you teaching this class again?" mentality and I've just about given up. this is the last place I can think of to ask for help and get something meaningful back. If anyone can help me out, I'd be very greatful
__________________
Xbox Live Gamertag: drgnmstr44
PSN tag: drgnmstr44
Respond to this Post
Old 07-21-2010
spacer
LazerFX LazerFX is offline
The LazerFX.
LazerFX's Avatar
Subscriber
 
Join Date: Apr 2006
Fwang: 275"

Location: England.
For the first problem, you could try setting the .innerHTML value of the span to something - might not work with a <span>, could work with a <div> or a <td>...

As to the pop-up window... easiest way I can think of is to use a queryString, and parse the query string to pull the data out...

I'm a little hazy on the specifics, because basically I'd be going in and seeing what works, but that should get you pointed in sort of the area you're aiming for... I hope
__________________
My Machines
Do not mess with the affairs of Dragons, for thou art crunchy, and good with ketchup.
Respond to this Post
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


bottom left

All times are GMT -7. The time now is 06:03 PM.



bottom right
Powered by vBulletin Version 3.7.2 Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Artwork and Content Copyright © GUComics.Com. All rights reserved.