![]() |
THE TWO MORE MINUTES NETWORK:
GUComics |
GUForums |
GUGaming |
ItsaKon |
Raptor Guts |
|
|
||
|
aka Mike Garhart
|
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:
|
|
| Respond to this Post |
|
|
|
|
The LazerFX.
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 ![]() |
| Respond to this Post |
|
||||||