0

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.

<HTML>
<HEAD>
<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);          
           }
</script>

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

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

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

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

<td> "Name your characters occupation";</td><td><select id='occupation'>
    <option>Please Choose</option>
    <option>Butcher</option>
    <option>Baker</option>
    <option>Cleaner</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>
    <option>Chopped</option>
    <option>Cooked</option>
    <option>Cleaned</option>
</select><br /></td></tr>

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

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

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

<TR>
  <TD colspan=3>
            <INPUT TYPE="button" VALUE="Submit" 
            onClick="display(this.form)">
            <INPUT TYPE="reset" VALUE="Reset"
            onMouseOver="window.status='Clears the form' "
            onMouseOut="window.status='Limerick Generator' ">
  </TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>

Hope you can help :D

ChargrO

2
Contributors
3
Replies
18
Views
4 Years
Discussion Span
Last Post by IIM
1

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 .

0

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.