Hi guys

I'm fairly new to java script and was wondering if I could get some help with this, please forgive the probably messy code.

<TITLE>Limerick Generator</TITLE>
<script type ="text/javascript">
           function display(f) 
                f.result.value = eval((f.character.value) + (f.body.value) + (f.characterrhyme.value) + (f.occupation.value) + (f.task.value) + (f.verb.value) + (f.direction.value) + (f.directionrhyme.value));
                document.write("There was a " + f.body.value + f.occupation.value + "called " + f.character.value + "who " + f.task.value + "more than he wanted to " +  f.characterrhyme.value + "one day he " + f.verb.value + f.direction.value + "and said with a " + f.directionrhyme.value + "that eating was more than a " + f.characterrhyme.value);          

<BODY BGCOLOR="moccasin" TEXT="#000000" LINK="#0000ff" VLINK="#800080" ALINK="#ff0000">
<CENTER><H2>Limerick Generator</H2></CENTER>
<FORM NAME="Limerick Generator">
  <TD WIDTH=25%>
  <TD WIDTH=25% >
            <B> Answer </B>

<td> "Name of your character";</td><td><select name='character'>
    <option>Please Choose</option>
</select><br /></td></tr>

<td> "Please choose a body type";</td><td><select name='body'>
    <option>Please Choose</option>
</select><br /></td></tr>

<td> "Two words that rhyme with your character's name";</td><td><select  name='characterrhyme'>
    <option>Please Choose</option>
</select><br /></td></tr> 

<td> "Name your characters occupation";</td><td><select id='occupation'>
    <option>Please Choose</option>
</select><br /></td></tr>

<td> "What is the past tense of a task your character might do at work";</td><td><select name='task'>
    <option>Please Choose</option>
</select><br /></td></tr>

<td> "Pick a past tense verb";</td><td><select name='verb'>
    <option>Please Choose</option>
</select><br /></td></tr>

<td> "Pick a direction";</td><td><select name='direction'>
    <option>Please Choose</option>
</select><br /></td></tr>

<td> "Pick a word that rhymes with your direction";</td><td><select name='directionrhyme'>
    <option>Please Choose</option>
</select><br /></td></tr>

  <TD colspan=3>
            <INPUT TYPE="button" VALUE="Submit" 
            <INPUT TYPE="reset" VALUE="Reset"
            onMouseOver="window.status='Clears the form' "
            onMouseOut="window.status='Limerick Generator' ">

Hope you can help :D


4 Years
Discussion Span
Last Post by IIM

the error is in lin 7.
Why are you using eval function here??

The eval() function evaluates or executes an argument.

If the argument is an expression, eval() evaluates the expression. If the argument is one or more JavaScript statements, eval() executes the statements.
this is the use of eval function.

Moreover there is no element with attribute name result in your form and you are not using it further also.So you can comment that or if you require that then make a field with name as "result" and remove eval() from it .


ChargrO :- Is your problem solved?If yes mark the thread as solved or else what is the problem you are still facing?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.