Skip to main content
GameDev.net gamedev.net
🔒 Locked

[web] having basic trouble with html forms and javascript

Started by JavaMava Nov 30, 2008 at 11:28 PM 7 replies 1.1k views
Original Post
JavaMava
JavaMava
It's for an assignment. Part one was to make form for ordering condos, which I've done. Part two is to write some &#106avascript that will validate whats been entered. I've looked over the examples, but just can't get it working. I know it's a lot to ask, but could one of you give me a quick working example of html code that allows you to enter some text (including the form parameters to load in the js file) as well as a js file that displays the text in a new window? Not using alert. There's a ton more to the assignment to that, but I think that's simple enough and with a working example of that I could do the rest. Heres a basic idea, couldn't find a html tag
Quote:
Wan
Wan
Quote:
Original post by JavaMava
I know it's a lot to ask, but could one of you give me a quick working example of html code that allows you to enter some text (including the form parameters to load in the js file) as well as a js file that displays the text in a new window? Not using alert.

No, it's your assignment, not ours. And please use the source tags when you include code.

I have no problem to give you some pointers to help you on your way, but start with asking a concrete question. I see you've written some code already, what is it that is causing you problems?
JavaMava
JavaMava
Quote:
Original post by WanMaster
Quote:
Original post by JavaMava
I know it's a lot to ask, but could one of you give me a quick working example of html code that allows you to enter some text (including the form parameters to load in the js file) as well as a js file that displays the text in a new window? Not using alert.

No, it's your assignment, not ours. And please use the source tags when you include code.

I have no problem to give you some pointers to help you on your way, but start with asking a concrete question. I see you've written some code already, what is it that is causing you problems?


I realize it's my assignment. I'm not asking you to do my assignment. I'm asking for as simple of an example as I thought possible to show me where I'm going wrong in this. I've included code of what I needed, so as to show I'm not trying to get you guys to do it for me, just show me a working example of what I have.

They're are literally dozens of input fields in my form that need a variety of validation checks. All I'm asking is for a start to get the form and java script "talking" to each other.

I realize your hostility is based around people coming here asking "can you write a calculator program for me" or "I need a free programmer for a game idea I have", but I'm not one of them.




Anyways, there are now source tags so you guys can read it easier. As for a concrete question. When the user click on the submit button I want the js to start the validation. The example up there being if errors > 0 then I need it to open a new window and display what the errors are. Also if false I'd like it to not submit the info and allow the user to try again on the form.

I'll greatly appreciate any help I receive.
swiftcoder
swiftcoder
Your html code look as if it does exactly what you describe, so any problems you are having are probably in the &#106avascript. I notice immediately that your checkForm() function doesn't every call validateName()...
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
JavaMava
JavaMava
Quote:
Original post by swiftcoder
Your html code look as if it does exactly what you describe, so any problems you are having are probably in the &#106avascript. I notice immediately that your checkForm() function doesn't every call validateName()...


whoops, lol.

That was a copy pasta error from my code. My actual document I'm working on is a few hundred lines longer.

errors += validateName();

is the line I've added. If an error is found in validateName, it returns a value higher than 0. That value is then added on to errors.

I have it open a new tab (might be a firefox thing), but not a window. Even more importantly there's no content in this new tab, where I am expecting everything from the document.write statements. It's stuck in a continual load or something.

Finally my form submits the info even though a false should be returned.

Thanks a lot for your help, but I'm a bit away from my goal still.
swiftcoder
swiftcoder
Quote:
Original post by JavaMava
I have it open a new tab (might be a firefox thing), but not a window.
That is a firefox thing, it always opens new tabs, rather than windows - should open a new window under IE or Safari.

Quote:
Thanks a lot for your help, but I'm a bit away from my goal still.
Documentation is always a good thing to have, in particular try here.
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
JavaMava
JavaMava
Quote:
Original post by swiftcoder
Quote:
Original post by JavaMava
I have it open a new tab (might be a firefox thing), but not a window.
That is a firefox thing, it always opens new tabs, rather than windows - should open a new window under IE or Safari.

Quote:
Thanks a lot for your help, but I'm a bit away from my goal still.
Documentation is always a good thing to have, in particular try here.


Thanks a ton I got it to work. Now I can go on with the rest of my assignment.

THANKS!
Wan
Wan
Quote:
Original post by JavaMava
I realize your hostility is based around people coming here asking "can you write a calculator program for me" or "I need a free programmer for a game idea I have", but I'm not one of them.

I apologize if my reaction came across as hostile, which was certainly not my intention. I guess in hindsight you did ask somewhat of a concrete question (opening a new window), but because it was convoluted by the unreadable code sample it read as a "here's my code why doesn't it work" kind of post.

But you've got it working, that's all that matters.
JavaMava
JavaMava
Quote:
Original post by WanMaster
Quote:
Original post by JavaMava
I realize your hostility is based around people coming here asking "can you write a calculator program for me" or "I need a free programmer for a game idea I have", but I'm not one of them.

I apologize if my reaction came across as hostile, which was certainly not my intention. I guess in hindsight you did ask somewhat of a concrete question (opening a new window), but because it was convoluted by the unreadable code sample it read as a "here's my code why doesn't it work" kind of post.

But you've got it working, that's all that matters.


I accept your apology. In the future I'll try and ask more concrete questions and I'll use source tags so you guys can read it easily. In the end I'll be the one who benefits from it.

Thanks.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.