SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: JQuery issue

  1. #1
    SitePoint Zealot
    Join Date
    Dec 2010
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JQuery issue

    What im trying to do is changing
    dropdown menu values
    the Ajax.php files will print
    this:
    <option value="..">...</option>

    the problem is i am wrapping other content with the
    <div id="result2">CONTENT</div>
    and for some reason it doesnt work when I wrap content
    only when I dont wrap anything it works
    like that:
    <div id="result2"></div>

    but I want the JQuery to delete the content inside the div and write what he gets from the Ajax.php.
    So how can I do that if it won't work when Im wrapping the content with the div?
    Code JavaScript:
    <select>
     
    <div id="result2">
    <option value="A">A</option>
    <option value="B">B</option>
    <option value="C">C</option>
    </div>
     
    </select>
     
    <script>
       function displayVals() {
    	var singleValues = $("#form1").val();
     
    	$.get("ajax.php", { id: singleValues },
    	   function(data){
    		$( "#result2" ).html(data);
    	});
         }
    $("select").change(displayVals);
    displayVals();
    </script>

  2. #2
    SitePoint Zealot
    Join Date
    Dec 2010
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Solved
    just wrapped the "<select>" too
    and its working now.

  3. #3
    Forums Designer
    Join Date
    Jun 2004
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your solution is wrong. DIV should never be inside SELECT, remove it. SELECT can include only OPTGROUP and OPTION tags.

  4. #4
    SitePoint Zealot
    Join Date
    Dec 2010
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats what I did.. I warpped the whole SELECT
    and deleted the div inside..
    Thanks anyway

    I am still having problem in running 2 functions in JQuery
    help me here if you can
    http://www.sitepoint.com/forums/java...ml#post4880431


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •