pwcahyo
pwcahyo

Reputation: 67

select value from dropdown menu

I want to make this source code, I copy this source code in my notepad and I paste it in one file, include CSS, JavaScript and HTML. The file name is sel.php.

I take the source code from http://jsfiddle.net/davidThomas/x5YW3/

I include my CSS with:

<style type="text/css">
----this_source_css----
</style>

JavaScript with :

<script type="text/javascript">
----this_source_javascript----
</script>

And HTML in:

<html>
<body>
----html_source_code----
</body>
</html>

But this code does not work in my copy paste, whereas I run in jsfiddle working fine, what might be wrong?

Upvotes: 0

Views: 200

Answers (2)

Johnbabu Koppolu
Johnbabu Koppolu

Reputation: 3252

Just a guess - include your javascript-

$(document).ready(function(){
// your code here
});

Also make sure you included JQuery source in your file.

However, Your fiddle code is being executed "onLoad" - check the dropbox below "Choose Framework".

As Pekka pointed out, if you do intend your code to run after "load" instead when your dom is ready, you can use this -

$(document).load(function() {
// your code here
});

An explanation of the difference between the two events is here

Upvotes: 1

Talha Akbar
Talha Akbar

Reputation: 10030

As @Boaz Said:

You haven't included jQuery in your document. Get the latest version from jquery.com and also use this:

$( function() {

// paste js code here

});

Upvotes: 1

Related Questions