Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Difference between IE and Firefox

Status
Not open for further replies.

michaelh613

Programmer
Nov 16, 2007
9
US
In Firefox it works correctly getting variables for state category and subcategory from my form. However in IE it only gets category and subcategory. Is there a bug is IE that would cause this. Is there a extension similiar to firebug that can be used to research these type of errors

Code:
var stateSelect = document.getElementById('state') 
var categorySelect = document.getElementById('category')
var subcategorySelect = document.getElementById('subcategory')

var state = stateSelect.options[stateSelect.selectedIndex].value
var category = categorySelect.options[categorySelect.selectedIndex].value   
var subcategory = subcategorySelect.options[subcategorySelect.selectedIndex].value
var url="getcity.php"

url=url+"&state="+state
url=url+"?category="+category
url=url+"&subcategory="+subcategory

alert ("url is " +url) 
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged3 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
 
[1] If you set up url in that order, you have to be careful on the ? and &.

>url=url+"&state="+state
[tt]url=url+"[highlight]?[/highlight]state="+state[/tt]
>url=url+"?category="+category
[tt]url=url+"[highlight]&[/highlight]category="+category[/tt]

[1.1] I hope you know the operator += to shorten them a bit.

[2] Minor point: you can simplify the retrieval of value, for instance.
[tt]> [/tt]var state = stateSelect.options[stateSelect.selectedIndex].value
It would be the same as this.
[tt] var state = stateSelect.value[/tt]

[3] Hidden possible major: You have to make a distinction between the .value and .text. Make sure you script the value properly and not leave them out, ie won't take text as the proxy of value in that case. But since you get category and subcategory, I think there you've done it properly.
 
Can you explain the how the .value and .text issue works. I've switched the code to use your suggestions and still have the problem and wonder if that could be the issue

It's so confusing because it works in firefox.

I'll take any suggestions for addons I can use that mimic the tools firefox has as well if anyone has an idea

Code:
function showCity()
{ 
	
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 
var stateSelect = document.getElementById('state') 
var categorySelect = document.getElementById('category')
var subcategorySelect = document.getElementById('subcategory')


var state = stateSelect.value
var category = categorySelect.value
var subcategory = subcategorySelect.value
var url="getcity.php"
alert ("state is " +state)

url=url+"?category="+category
url=url+"&subcategory="+subcategory
url=url+"&state="+state

alert ("url is " +url) 
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged3 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
 
[3.1] What I mean is simply this.
[tt] <option value="dot_value_here">dot_text_here</option>[/tt]
But I think you should have it right as I said you've category and subcategory correctly.

[4] But with the additional lines, you may have a problem with comparing null. Make sure the GetXmlHttpObject() function return null if it fails to establish the object.

[5] You have to further taken care of unsafe characters in state, category and subcategory. But again if it works in ff, there probably won't contain any and hence shouldn't pose a problem for ie.
[tt]
url=url+"?category="+encodeURI(category)
url=url+"&subcategory="+encodeURI(subcategory)
url=url+"&state="+encodeURI(state)
[/tt]
 
Strange thing I am generating most of my html dynamically using PHP but I hadn't added that to the state field yet. So I added that and then the problem resolved itself.

I have no idea what is different in how my html is outputted using PHP but it works now. Sometime in the future I will have to go back and see the difference.

Thanks for the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top