Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jul 2006
    Posts
    175
    Thanks
    14
    Thanked 1 Time in 1 Post

    jquery return ok in Firefox, not so in IE

    Hi,
    Code:
    $(document).ready(function(){
    	$.post("volgetname.php", function(data){  
    	$('select#vol').html(data);
    	alert("Select value is: " + data);
    	//alert returns correct data in firefox and ie				
    		});											  
    	$("#vol").change(function(){                   
    		displayrecord();
    			});										  
    	function displayrecord(){
    //next line should get value of selected option					  
    var volnum=$('select#vol'). val()
    alert("value at line 79: " + volnum);
    //This alert in firefox returns the value of the select option. In ie, it returns undetermined. 
    etc.
    etc.
    I am trying to identify an issue between firefox and IE.
    The entire program runs well in firefox.
    I have located the area at which ie quits cooperating.
    The method of getting the selected option value of a select box on a form is causing a conflict in ie.

    This is the form:
    <form name="volselect" id="volselect" method="post" action="volgetname.php">
    <select name="vol" id="vol" size="1" style="width:20em">
    <option>FullName</option>
    </select>
    </form>
    Shoud I change the syntax for the select.val for IE?

    Thanks,

    Andy
    Last edited by 1andyw; 04-13-2009 at 08:53 AM. Reason: RESOLVED

  • #2
    Regular Coder Iszak's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Western Australia
    Posts
    332
    Thanks
    2
    Thanked 58 Times in 57 Posts
    I have no idea, I tested this and it seemed to work, but maybe try this code I did.
    Code:
    $(document).ready(function(){
      jQuery.post('volgetname.php', function(response){
        $('#vol').html(data);
      
        alert("Select value is: " + data);
      });
      
      $('#vol').change(function(){
        var volnum = $(this).val();
        alert("Value at line 79: " + volnum);
      });
    });

  • #3
    Regular Coder
    Join Date
    Jul 2006
    Posts
    175
    Thanks
    14
    Thanked 1 Time in 1 Post
    Substituted your code for mine the result is the same except it now throws errors in ff also:
    Code:
    Notice: Undefined offset: 2 in /home/unix/web/htdocs/m/h/mhanp.org/www/aandymdb/volgethours.php on line 10
    mysql_error()
    Which leads back to the problem of the select option value not being recognized.

  • #4
    Regular Coder Iszak's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Western Australia
    Posts
    332
    Thanks
    2
    Thanked 58 Times in 57 Posts
    I don't see how the replaced code could have caused that error - because that's a PHP error, and looking at your request, it's not like you're sending any data to the page which I've forgotten, that error is completely unrelated to the JavaScript. How about instead of using .val() use .html() when getting the value of the option so var volnum = $(this).html();

    If you're trying to do an AJAX request with the select data, you need to pass it otherwise it won't work - because I presume volgetname.php has some dependency on the POST content?

  • #5
    Regular Coder
    Join Date
    Jul 2006
    Posts
    175
    Thanks
    14
    Thanked 1 Time in 1 Post
    Iszak,

    You are correct. The php was in error and messed up the script.

    Changed:
    Code:
    <option> . $var . </option>
    to:

    Code:
    <option . $var .> . $var . </option>
    Thank you.


  •  

    Posting Permissions

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