Jump to content

The last poster wins


TheCalliton

Recommended Posts

:confused: Dang its warm for a change here :thumbsup: , 24c plus humidity. it feels like 31c here. Summer has arrived :biggrin:

Edited by Thor.
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.

 

The "result" is fine, you're letting the program know where to send the resulting text.

 

I think your problem is that you just tacked on

 

 

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

 

without giving it a proper beginning, a function.

 

I searched a bit and the proper way to use this always began with a function.

 

<html>
<head>
<script>
function getValue()
  {
  var x=document.getElementById("myHeader");
  alert(x.innerHTML);
  }
</script>
</head>
<body>

<h1 id="myHeader" onclick="getValue()">Click me!</h1>

</body>
</html>

 

See the function at the beginning?

 

document.getElement is usually used within a function afaik.

 

Hope that helped:P I know a bit of HTML CSS and JS, but I'm at the beginning of JS.

 

Ok, I'll try that in a bit. Thanks. :)

 

 

Loving the warm weather today, bout time we got some good weather. Having a few beers listening to some old school stuff :happy:

http://www.youtube.com/watch?v=o7MhpFF1vv0

 

Love this song.

Link to comment
Share on other sites

Soo not used to the heat lol, its great though its finally arrived, but when it does come we still complain lol.

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...