0

I have this in my html

 function populate(myop) {
        var selection = myop.options[myop.selectedIndex].text;

        PopulateTaskddl(selection);
    }

  <select id="ddljobname_In" name="cpname_job" onchange="populate(this.value)" style="margin-left: 10px; color: Black;">
                </select>

it gives me error says " Populate is undefined ..

Any help ?

4
  • Put the script after the HTML Commented Aug 7, 2014 at 21:33
  • 2
    Is your populate function inside inside a <script></script> tag? Commented Aug 7, 2014 at 21:34
  • yes.Issue is resolved. Thanks @tymeJV Commented Aug 7, 2014 at 21:38
  • No. :) it actually didn't give an error like that Commented Aug 7, 2014 at 21:40

2 Answers 2

2

You have to put your JavaScript function in script tags, so that your browser knows that it's JavaScript, not HTML.

JS is not HTML and you have to declare so. You might start with some tutorials and learn how to use HTML, CSS, JavaScript & co. before posting on a Q&A platform like StackOverflow.

<script>
    function populate(myop) {
        var selection = myop.options[myop.selectionIndex].text;
        PopulateTaskddl(selection);
    }
<script>
<select id="ddljobname_In" name="cpname_job" onchange="populate(this.value)" style="margin-left: 10px; color: Black;">
</select>
Sign up to request clarification or add additional context in comments.

Comments

-1
<select id="ddljobname_In" name="cpname_job" onchange="populate(this)" style="margin-left: 10px; color: Black;">
</select>
<script type="text/javascript">
    function populate(myop) {
        var selection = myop.options[myop.selectedIndex].text;
        PopulateTaskddl(selection);
    }
</script>

3 Comments

You shouldn't. It's not your solution... =)
Yeah you actually right around 100 percent .. Thanks @tymeJV
Can anyone do it then :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.