We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I need help with the fixing the drop down list I made that is not working. If you go to my site at http://people.ucsc.edu/~mafiguer/hello_java.html , type in your name in the empty box where it asks, select from the drop down menu words (hate, hello, love, like), and then click the greet button at the bottom, it will prompt a message. If hate is selected , the program with run the words "I don't like you _______". If hello is selected, it says "Hello there _______". Then with love and like, I only get the words error (when it should be "Hello there ______ " for both of them. Not sure what part I set up wrong but here is my code (just the section I need help with)
<!-- *****************************************************
Creates a pull-down menu of size 1 that allows you to select an option.
Options are listed within. You can add more options.
****************************************************** -->
<select name="my_menu" size="1">
<option value="Hate_value">Hate</option> <!-- shows word Hate in menu -->
<option value="Hello_value">Hello</option> <!-- shows word Hello in menu -->
<option value="Love_value">Love</option> <!-- shows word Hate in menu -->
<option value="Like_value">Like</option> <!-- shows word Hello in menu -->
</select>
<pre> <!-- PRE puts pre formatted text on the screen. In this case, we are adding vertical space. -->
</pre>
<pre> <!-- PRE puts pre formatted text on the screen. In this case, we are adding vertical space. -->
</pre>
<pre> <!-- PRE puts pre formatted text on the screen. In this case, we are adding vertical space. -->
</pre>
<center>
<!-- *********************************************************
A button with the word greet will appear because of this call.
The button when pushed will call the function "my_function"
DO NOT MODIFY THIS
********************************************************** -->
<input name="greet_button" value="greet" onclick="this.form.the_result_of_the_greeting.value= my_function(
this.form.name_of_person.value,
this.form.my_menu.options[ this.form.my_menu.selectedIndex].value)" type="button">
<!-- **********************************************
Makes a text box of size 35 which receives the
result of pushing the "greet" button
*********************************************** -->
<input name="the_result_of_the_greeting" size="35" type="text">
<pre> <!-- PRE puts pre formatted text on the screen. In this case, we are adding vertical space. -->
</pre>
<hr> <!-- HR is command which draws a line across the screen -->
<a href="http://people.ucsc.edu/~mafiguer/"
onMouseOver="document.bgColor='pink'; return true;"
onMouseOut="document.bgColor='blue'; return true;">
Visit Monica Figueroa's Page!
</a>
</center>
</form>
</body>
<!-- LONG COMMENT ****************************************************
When I press the greet button, I call the following function.
In other words, this function runs when the greet button is pressed.
DO NOT DELETE THIS FUNCTION
You may modify as needed by adding to the function.
FUNCTION: my_function(value1, value2)
RESULT: returns a string of characters, stored in resulting_string
ARGUMENT1: value1 - Takes the name of a person
ARGUMENT2: value2 - Takes the name of an operation
****************************************************************** -->
<script language="javascript">
function my_function(value1, value2, value3, value4)
{
<!-- Start with an empty string called resulting_string. -->
var resulting_string = "";
<!-- If no name was given... -->
if (value1 == "")
{
<!-- store "WHO?" in resulting_string. -->
resulting_string = "WHO?";
}
<!-- otherwise, if hello was selected in the menu... -->
else if ( value2 == "Hello_value" )
{
<!-- store "Hello There" and the person's name in resulting_string. -->
resulting_string = "Hello There " + value1;
}
<!-- Otherwise, if hello was selected in the menu... -->
else if ( value2 == "Hate_value" )
{
<!-- store "I don't like you" and the person's name in resulting_string. -->
resulting_string = "I Don't Like You " + value1;
}
<!-- otherwise, if hello was selected in the menu... -->
else if ( value3 == "Love_value" )
{
<!-- store "Hello There" and the person's name in resulting_string. -->
resulting_string = "Hello There " + value1;
}
<!-- Otherwise, if hello was selected in the menu... -->
else if ( value4 == "Like_value" )
{
<!-- store "Hello There" and the person's name in resulting_string. -->
resulting_string = "Hello There " + value1;
}
<!-- Otherwise, if nothing above happens... -->
else
{
<!-- store "ERROR HAS OCURRED" in resulting_string (because something should have happened before this). -->
resulting_string = "ERROR HAS OCCURRED";
}
<!-- Finally, return whatever was stored in resulting_string. -->
return resulting_string;
}
</script>
also please hurry I need to submit this in 20 minutes or I get 0% for my grade so PLEASE HURRY
Answers
This forum is about Processing framework and its many variants.
However, your code is pure HTML! :-@
My bet is that value3 & value4 don't exist and you should keep on checking value2 for all drop-down options!