0

My Dropdown menu,

   <select  id="type" name="name" onchange="getval(this);">
    <option value="1">One</option>
    <option value="2">Two</option>
    <option value="3">Two</option>
    </select>
    <select id="size">
    <option value="">-- select one -- </option>
    </select>

My javascript code,

<script type="text/javascript"  src="/code/asset/js/jquery-1.10.2.js" charset="utf-8">
</script>//i want to include js file

 <script type="text/javascript">
function getval(sel) {
    var val = sel.value;
    if (val == 1) {
        $("#size").html("<option value='1'>item1: test 1</option><option value='test2'>item1: test 2</option>");
    } else if (val == 2) {
        $("#size").html("<option value='2'>item2: test 1</option><option value='test2'>item2: test 2</option>");

    } else if (val == 3) {
        $("#size").html("<option value='3'>item3: test 1</option><option value='test2'>item3: test 2</option>");

    }

}

Path for jquery file

  C:\xampp\htdocs\code\asset\js\jquery-1.10.2.js

Is there any mistake in including jquery?

3 Answers 3

1

Try

<script type="text/javascript" src="<?php echo base_url('code/asset/js/jquery-1.9.1.js')?>"></script>

Or to use directly from the jQuery site use the following

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
0
1

Write:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
2
  • code.jquery.com/jquery-1.10.2.min.js i used this code in my jquery-1.9.1.js file
    – darshan
    Jul 5, 2013 at 9:05
  • Didnot understand your comment above actually you need to include the JQuery library only once in a page. Add the above line in your header section and dont include any other version of JQuery in the page again. @darshan
    – Nil'z
    Jul 5, 2013 at 10:21
1
//Use following

<script type="text/javascript" src="<?php echo base_url().'code/asset/js/jquery-1.9.1.js'; ?>"></script>

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.