Jump to content

The last poster wins


TheCalliton

Recommended Posts

Does anyone here know much HTML/JavaScript? I've got a problem in this code that I just can't pinpoint!

 

<html>

<head>

        <script type="text/javascript">
        function getSelection()
        {
		dropdownselect[0] = "Nothing";
                dropdownselect[1] = "Maps";
                dropdownselect[2] = "Weather";
                dropdownselect[3] = "Beach Conditions";
                dropdownselect[4] = "Traffic";
                list = document.getElementById("select selection");
                index = list.selectedIndex;
                theselection  = list.options[index].text;
                document.getElementById("result").innerHTML = "You have chosen " + dropdownselect[index]
        }
        </script>
	
</head>

<body>

        <center>
	<select id="select selection" onchange="getSelection()">
	<option selected="selected"> Nothing </option>
	<option> Maps </option>
	<option> Weather </option>
	<option> Beach Conditions </option>
	<option> Traffic </option>
	</select>
	<center>

	<p id="result"></p>

</body>

</html>

These are the bits that aren't working. What I'm trying to do, is make it so that when I select one of the options in the dropdown menu, it displays the message "You have chosen " + dropdownselect[index] with the variables filled in. Problem is, it doesn't even show up at all. Can anyone help? Or should I start over?

I have looked over it, then I copied it and did let it run on HTML script tester site, because I didn't find anything at first glance.

Result : the displayed script worked. The variables showed in a drop down menu and where selectable.

:psyduck: No Idea why above script isn't working for you.

Link to comment
Share on other sites

 

Does anyone here know much HTML/JavaScript? I've got a problem in this code that I just can't pinpoint!

 

<html>

<head>

        <script type="text/javascript">
        function getSelection()
        {
		dropdownselect[0] = "Nothing";
                dropdownselect[1] = "Maps";
                dropdownselect[2] = "Weather";
                dropdownselect[3] = "Beach Conditions";
                dropdownselect[4] = "Traffic";
                list = document.getElementById("select selection");
                index = list.selectedIndex;
                theselection  = list.options[index].text;
                document.getElementById("result").innerHTML = "You have chosen " + dropdownselect[index]
        }
        </script>
	
</head>

<body>

        <center>
	<select id="select selection" onchange="getSelection()">
	<option selected="selected"> Nothing </option>
	<option> Maps </option>
	<option> Weather </option>
	<option> Beach Conditions </option>
	<option> Traffic </option>
	</select>
	<center>

	<p id="result"></p>

</body>

</html>

These are the bits that aren't working. What I'm trying to do, is make it so that when I select one of the options in the dropdown menu, it displays the message "You have chosen " + dropdownselect[index] with the variables filled in. Problem is, it doesn't even show up at all. Can anyone help? Or should I start over?

I have looked over it, then I copied it and did let it run on HTML script tester site, because I didn't find anything at first glance.

Result : the displayed script worked. The variables showed in a drop down menu and where selectable.

:psyduck: No Idea why above script isn't working for you.

The problem is that

 

 

document.getElementById("result").innerHTML = "You have chosen " + dropdownselect[index]

 

should show the text "You have chosen", after you select one of the options in the drop down menu.

 

I'm afraid I dont know enough js to see where the problem is right now. Which means I need to learn more.

 

 

Maybe try adding a function before the document.get and assign it to the dropdown menu selectors.

Edited by Iv000
Link to comment
Share on other sites

Hmm, yeah, perhaps I'll sleep on it and try again tomorrow.

 

Oh yeah, and the purpose of this code is to display a separate image for each item in the drop down menu. I just thought I'd get some text to work first, and then change it to an image afterwards.

Link to comment
Share on other sites

Does anyone here know much HTML/JavaScript? I've got a problem in this code that I just can't pinpoint!

 

<html>

<head>

        <script type="text/javascript">
        function getSelection()
        {
		dropdownselect[0] = "Nothing";
                dropdownselect[1] = "Maps";
                dropdownselect[2] = "Weather";
                dropdownselect[3] = "Beach Conditions";
                dropdownselect[4] = "Traffic";
                list = document.getElementById("select selection");
                index = list.selectedIndex;
                theselection  = list.options[index].text;
                document.getElementById("result").innerHTML = "You have chosen " + dropdownselect[index]
        }
        </script>
	
</head>

<body>

        <center>
	<select id="select selection" onchange="getSelection()">
	<option selected="selected"> Nothing </option>
	<option> Maps </option>
	<option> Weather </option>
	<option> Beach Conditions </option>
	<option> Traffic </option>
	</select>
	<center>

	<p id="result"></p>

</body>

</html>

These are the bits that aren't working. What I'm trying to do, is make it so that when I select one of the options in the dropdown menu, it displays the message "You have chosen " + dropdownselect[index] with the variables filled in. Problem is, it doesn't even show up at all. Can anyone help? Or should I start over?

 

I don't know JavaScript but I get the basics, and it looks to me as if you're trying to call something that isn't there. You call dropdownselect[index] when the dropdownselect has no function other than standing there, the indexes aren't assigned to actual options. The "result" doesn't seem to contain any results either.

 

Basically, I think you're trying to call an ID that isn't specified. Also, I believe the function for printing in JavaScript is document.write() :confused:

Edited by Werne
Link to comment
Share on other sites

 

Does anyone here know much HTML/JavaScript? I've got a problem in this code that I just can't pinpoint!

 

<html>

<head>

        <script type="text/javascript">
        function getSelection()
        {
		dropdownselect[0] = "Nothing";
                dropdownselect[1] = "Maps";
                dropdownselect[2] = "Weather";
                dropdownselect[3] = "Beach Conditions";
                dropdownselect[4] = "Traffic";
                list = document.getElementById("select selection");
                index = list.selectedIndex;
                theselection  = list.options[index].text;
                document.getElementById("result").innerHTML = "You have chosen " + dropdownselect[index]
        }
        </script>
	
</head>

<body>

        <center>
	<select id="select selection" onchange="getSelection()">
	<option selected="selected"> Nothing </option>
	<option> Maps </option>
	<option> Weather </option>
	<option> Beach Conditions </option>
	<option> Traffic </option>
	</select>
	<center>

	<p id="result"></p>

</body>

</html>

These are the bits that aren't working. What I'm trying to do, is make it so that when I select one of the options in the dropdown menu, it displays the message "You have chosen " + dropdownselect[index] with the variables filled in. Problem is, it doesn't even show up at all. Can anyone help? Or should I start over?

 

I don't know JavaScript but I get the basics, and it looks to me as if you're trying to call something that isn't there. You call dropdownselect[index] when the dropdownselect has no function other than standing there, the indexes aren't assigned to actual options. The "result" doesn't seem to contain any results either.

 

Basically, I think you're trying to call an ID that isn't specified. Also, I believe the function for printing in JavaScript is document.write() :confused:

 

Hmm, yeah I can see how that works. I'll have a go at fixing it tomorrow... so tired.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...