English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I'm creating a little mad libs type thing... I'm taking a course in javascript and the courseware isn't working properly and I won't see my counsler (from camp) until later tomorrow... plus, he lost is voice so I don't know how much he can help...

2006-07-25 14:42:40 · 4 answers · asked by Rachel 2 in Computers & Internet Programming & Design

http://www.omgpage.net/~hawt/JavaMadlibTest.txt

That's the code I wrote up. It's supposed to ask you questions, then in the end it will put all the answers into an alert window.

2006-07-25 14:56:13 · update #1

The problem is that when you try it, it won't let you press submit. I worked off a small base code... then the courseware crapped out so I decided to try myself. I didn't do too well...

2006-07-25 14:57:05 · update #2

4 answers

create a function like this in the language=javascript

function doAlert() {
var verbEd = document.getElementById('field0').value;
var country = document.getElementById('field1').value;
var noun ... ;
var bodyPart ... ;
var verbCat ...;
var nounDog ... ;
var yourName ...;
alert('Here is the story... I ' + verbEd + ' across the ' + country);
}

i scrapped the inputs you had and in the form tags do all questions and texboxes together to keep it simple:

use your p or br tags and angle brackets around the inputs...

Enter a verb ending in ed

input name="field0" id="field0" size=20 type="text" /

Enter a country

input name="field1" id="field1" size=20 type="text" /

...

then the submit is just like this (in angle brackets of course):

input type="button" value="Submit" onclick="javascript:doAlert();"

Hope this helps!
Ryan

2006-07-25 16:10:12 · answer #1 · answered by My name is Jonas 2 · 0 0

I can help but I need to know exactly what youre trying to do. If you can write code snippets, then I can help you fix it or modify in such a way that will make it work.

I cant just help you with javascript, because thats a very big topic and I'm not sure exactly what youre trying to do.

Try going to this website:
http://two.ucdavis.edu/~holland/caesar.html

It uses javascript to do mad libs type pages. Right click on the page and click on VIEW SOURCE and it will give you some idea of what you need to do.

2006-07-25 21:48:17 · answer #2 · answered by Sean I.T ? 7 · 0 0

Your button doesn't work because you have it set as:



That just indicates a button and not a submit button. You would need to write an onClick handler to be able to handle the button click.

If you want a submit button, change it to



As someone who's been writing code for some time...might I suggest you stop trying to handle all of your events inline with the HTML elements. It makes your code hard to read...and hard to debug.

2006-07-25 23:11:41 · answer #3 · answered by KidK 2 · 0 0

what kind of problem are you running into specifically?

2006-07-25 21:49:35 · answer #4 · answered by Anonymous · 0 0

fedest.com, questions and answers