Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-11-2009, 04:44 PM   PM User | #1
1andyw
Regular Coder

 
Join Date: Jul 2006
Posts: 171
Thanks: 13
Thanked 1 Time in 1 Post
1andyw is an unknown quantity at this point
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:
Quote:
<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
1andyw is offline   Reply With Quote
Old 04-11-2009, 05:01 PM   PM User | #2
Iszak
Regular Coder

 
Iszak's Avatar
 
Join Date: Jun 2007
Location: Perth, Western Australia
Posts: 332
Thanks: 2
Thanked 58 Times in 57 Posts
Iszak is an unknown quantity at this point
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);
  });
});
Iszak is offline   Reply With Quote
Old 04-11-2009, 05:38 PM   PM User | #3
1andyw
Regular Coder

 
Join Date: Jul 2006
Posts: 171
Thanks: 13
Thanked 1 Time in 1 Post
1andyw is an unknown quantity at this point
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.
1andyw is offline   Reply With Quote
Old 04-12-2009, 07:23 AM   PM User | #4
Iszak
Regular Coder

 
Iszak's Avatar
 
Join Date: Jun 2007
Location: Perth, Western Australia
Posts: 332
Thanks: 2
Thanked 58 Times in 57 Posts
Iszak is an unknown quantity at this point
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?
Iszak is offline   Reply With Quote
Old 04-13-2009, 08:57 AM   PM User | #5
1andyw
Regular Coder

 
Join Date: Jul 2006
Posts: 171
Thanks: 13
Thanked 1 Time in 1 Post
1andyw is an unknown quantity at this point
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.
1andyw is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:11 PM.


Advertisement
Log in to turn off these ads.