Discussion Locked

Passing function names from forms into J

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I'm trying to call on a function, the name of which is being passed into the JavaScript as a variable from a form. Unfortunately, JavaScript isn't recognizing the passed variable as a method.

I've presented the problem on two Web pages, a form page and a personalized message page. Only the age range radio buttons present this problem. Here's the URL for the first of the two pages: http:/www.geocities.com/eightypoundpack/submit-congrat2.html

Thanks in advance for any help you can give me.

2 replies

by jay eckles

Have you tried
exec( age ) ;

If not, why not do something like change the values of the age radio buttons on the form page to "child", "young adult", etc., then do something like

if( age == "child" ){
congratChild() ;
}

Just a thought.

Jay

by phil_perkins_1

Instead of doing document.write(age), all you need is eval(age). The function will take care of writing out the information. Your code looks like this:

// HERE'S WHERE I'm running into trouble. Can you spot the problem?

document.write(age);
+ age +

document.write("

");

document.write("

As you can see below, if the function names are entered directly into the code, they work without a hitch.<\/B><\/P>");

It should look like this:

// HERE'S WHERE I'm running into trouble. Can you spot the problem?

eval(age);

document.write("

");

document.write("

As you can see below, if the function names are entered directly into the code, they work without a hitch.<\/B><\/P>");

This discussion is closed to new replies.