2

I have an xml file like this:

<Product ID="1"  Code="AAAA AA"  Price="10"/>
<Product ID="2"  Code="AAAA  AA" Price="20"/>

I load 'Code' into tag

$('#select1').append($('<option></option>').val('1').html($(this).attr('Code')));

and I compare the value of select1 and the value from XML path:

function()
{ 
  var e = document.getElementById('textbox1');
  var proValue= e.options[e.selectedIndex].text;
  if($(this).attr('Code')==proValue)
  {
    var proPrice = $(this).attr('Price'); 
    document.getElementById('textfbox2').value=proPrice; 
  }
}   

The problem is that $(this).attr('Code')==proValue returns false with ID='2' as the value of it has two spaces. However, it works fine with the one with ID='1'.

Any ideas of how can I fix it?

4

1 回答 1

0

You can use the space character instead of typing the actual space. &#032; or &nbsp; It has worked for me in the past with similar problems.

于 2013-06-20T07:42:23.970 回答