|
-
Sep 28th, 2006, 06:43 PM
#1
Thread Starter
Hyperactive Member
Need Help with Javascript in Firefox [resolved]
I have the following javascript, what it does is listen to what the user inputs and displays it in a different section of the webpage, the text fields are fine but the dropdowns are giving me a little trouble, they work fine in IE, if I select something in the dropdown it instantly appears but if I select something in Firefox it seems like its lost. Below is my code all help is greatly appreciated.
HTML Code:
<script language="JavaScript">
if (window.addEventListener) {
addEHandler = function(obj, eventName, handler) {
obj.addEventListener(eventName, handler, false);
};
removeEHandler = function(obj, eventName, handler) {
obj.removeEventListener(eventName, handler, false);
};
}
else if (window.attachEvent) {
addEHandler = function(obj, eventName, handler) {
obj.attachEvent('on'+eventName, handler);
};
removeEHandler = function(obj, eventName, handler) {
obj.detachEvent('on'+eventName, handler);
};
}
var theDisplay4;
var city_id_text;
var theDisplay5;
var state_id_dropdown;
var theDisplay6;
var country_name_dropdown;
var theDisplay7;
function doTextKeyUp()
{
while (!theDisplay5.hasChildNodes())
theDisplay5.appendChild(document.createTextNode(''));
theDisplay5.firstChild.data = city_id_text.value;
while (!theDisplay6.hasChildNodes())
theDisplay6.appendChild(document.createTextNode(''));
theDisplay6.firstChild.data = state_id_dropdown.value;
while (!theDisplay7.hasChildNodes())
theDisplay7.appendChild(document.createTextNode(''));
theDisplay7.firstChild.data = country_name_dropdown.value;
}
addEHandler(window, 'load', function() {
city_id_text = document.getElementById('city_id_text');
theDisplay5 = document.getElementById('theDisplay5');
addEHandler(city_id_text, 'keyup', doTextKeyUp);
state_id_dropdown = document.getElementById('state_id_dropdown');
theDisplay6 = document.getElementById('theDisplay6');
addEHandler(state_id_dropdown, 'change', doTextKeyUp);
country_name_dropdown = document.getElementById('country_name_dropdown');
theDisplay7 = document.getElementById('theDisplay7');
addEHandler(country_name_dropdown, 'change', doTextKeyUp);
});
</script>
<strong><span id="theDisplay5"></span>, <span id="theDisplay6"></span> <span id="theDisplay7"></span></strong>
Last edited by mrstuff68; Oct 27th, 2006 at 01:03 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|