This works great in IE, but does not do anything in FireFox... Any ideas of what could be wrong with it? I checked all of the values (in IE through alert statements since nothing shows up in FireFox) and everything is valid.
Thanks... - function spanHide(spanNum){
-
for(startValue = 1;startValue <= 8;startValue++){
-
var currentSpan = eval("document.all.spanShip"+spanNum+"_"+startValue);
-
var InsureInfo_SpanInsure = eval(document.getElementById("spanInsure" + spanNum + "_1"));
-
currentSpan.style.display = "none";
-
}
-
alert("made it");
-
document.getElementById("length_" + spanNum).value = "";
-
document.getElementById("width_" + spanNum).value = "";
-
document.getElementById("height_" + spanNum).value = "";
-
document.getElementById("weight_" + spanNum).value = "";
-
-
document.getElementById("spanInsure" + spanNum + "_1").style.display = "none";
-
document.getElementById("spanInsure" + spanNum + "_2").style.display = "block";
-
//Code added to try and check the Firefox stuff
-
-
//End BS Fix
-
-
if (document.getElementById("type_" + spanNum).checked == false & document.getElementById("sAcc2_" + spanNum).checked == true)
-
{
-
document.getElementById("maxInsure_" + spanNum).value = "$500";
-
document.getElementById("spanInsure" + spanNum + "_1").style.display = "none";
-
document.getElementById("spanInsure" + spanNum + "_2").style.display = "block";
-
//alert(document.getElementById("type_" + spanNum).value + "letter");
-
}
-
else
-
{
-
document.getElementById("spanInsure" + spanNum + "_1").style.display = "none";
-
document.getElementById("spanInsure" + spanNum + "_2").style.display = "none";
-
}
-
}
21 2679
I only had to read two lines of code to see the (potential) problem. "document.all" is only supported by IE, you have to use getElementById (or others) for any other browser. I didn't ready any further, so I don't know if theres more.
That part is actually working fine in both browsers for whatever reason... It does not seem to like the - if (document.getElementById("type_" + spanNum).checked == false & document.getElementById("sAcc2_" + spanNum).checked == true)
parts of the code.
When I do - alert(document.getElementById("type_" + spanNum).checked)
I get the correct values to pop up in IE, but nothing comes up in FireFox.
When I do - alert(document.getElementById("type_" + spanNum).checked)
I get the correct values to pop up in IE, but nothing comes up in FireFox.
Have you given the span an id?
Yes... It is the same as the name. Should not make a difference right?
The spanNum is in that part of code is just a number that is appended to the name. Honestly I do not have a clue why, but it will not let me know the status of the checkbox. - document.getElementById("type_" + spanNum).checked
should return a true or false depending on what box is checked right? It shows up without an issue in IE.... Here is the code from the checkbox: - <tr>
-
<td valign="top" width="33%">
-
<span class="emphasis2">*</span>
-
<b>Type:</b>
-
</td>
-
-
<td valign="top">
-
<input type="radio" name="type_<%=spanLoop%>" id="type_<%=spanLoop%>_1" value="P"<% If curType <> "L" Then response.write "checked" End If %> class="radio" onClick="spanShow(<%=spanLoop%>)"/>
-
Package
-
<input type="radio" name="type_<%=spanLoop%>" id="type_<%=spanLoop%>_0" value="L" class="radio" onClick="spanHide(<%=spanLoop%>)"<% If curType = "L" Then response.write "checked" End If %>/>
-
Letter <b>( Less Than 8oz )</b></td>
-
</tr>
If you look carefully, it is not the same as the name.
The id has a "_0" or a "_1" at the end. IE erroneously accepts the name as an id which obviously then causes problems in other browsers.
Atli 5,058
Expert 4TB
If you look carefully, it is not the same as the name.
The id has a "_0" or a "_1" at the end. IE erroneously accepts the name as an id which obviously then causes problems in other browsers.
It could also be argued that IE intuitively predicts such errors and works around them ;)
It could also be argued that IE intuitively predicts such errors and works around them ;)
Yes, I always want my browser to guess at what I want rather than what I wrote **rollseyes**
The code above is checking for true/false, but the value for "checked" is "checked" and not true or false, but I'm not a js guy.
It could also be argued that IE intuitively predicts such errors and works around them ;)
That's not prediction; it's just plain wrong. A name is a name and an id is an id. If you want to get elements by name, there's a method for it: document.getElementsByName. Don't misuse document.getElementByID.
The code above is checking for true/false, but the value for "checked" is "checked" and not true or false, but I'm not a js guy.
That may be the case in HTML, but in Javascript, it's true/false. See link.
Atli 5,058
Expert 4TB
Yes, I always want my browser to guess at what I want rather than what I wrote **rollseyes**.
Yea I must say I totally agree with you there. I was merely demonstrating my awesome "Its not a bug... Its a feature!" ability :)
Would it matter if you actually set the 'checked' value to some value? Like say 'checked=true'.
Don't know what it would do but there is no such value.
Don't know what it would do but there is no such value.
In HTML, use [HTML]<input type="checkbox" ... checked="checked">[/HTML] and in Javascript, - document.getElementById("checkID").checked = true;
I understand that but I think he was wondering about this: - 1.
-
<input type="checkbox" ... checked="true">
Checked, in html, has no value of true.
Atli 5,058
Expert 4TB
Actually, after testing this, if the checkbox has the checked parameter in the HTML markup, no matter what value it may or may not have, it will be considered checked. In which case JavaScript will return true.
gits 5,390
Expert Mod 4TB
hi ...
just my two cents about that ... because it's the always misunderstood question about using javascript-obj-properties or setting node-attributes.
in case you set the checked="checked" attrib in html the nodes-cecked property:
equals true. when you set it to false the box will be unchecked and the property is false ... we set it ;) ... but! when you ask for the attrib: - node.getAttribute('checked')
equals 'checked' ... so there's a difference between js-properties and the nodes attributes. to uncheck the box with setting the attribute you have to use: - node.removeAttribute('checked');
-
hope this makes some confusion clear ... and shows, that we always should use ONE method in our code ... either the property-way OR the attribute way ... ok? which one you prefer is up to you ;) but to avoid confusion we shouldn't mix the possibilities ...
and of course ... it's my personal point of view ;)
kind regards
ps: a simple test: - <html>
-
<script>
-
function check_checkbox(box) {
-
alert('property = ' + box.checked);
-
alert('attribute = ' + box.getAttribute('checked'));
-
}
-
</script>
-
<body>
-
<input type="checkbox" onclick="check_checkbox(this);" checked="checked"/>
-
</body>
-
</html>
-
hi all!
i just came here for the answer to the first question in this thread.
Can someone help in answering how to make the Document.getElementById method to work in Firefox?
Thanks,
arsthegr8
Atli 5,058
Expert 4TB
Hi. Welcome to Bytes!
The 'document.getElementById()' method does work in Firefox.
It is case-sensitive tho so make sure it is written exactly like I wrote it.
Welcome to Bytes!
document.getElementById() works in Firefox, you just need to use it in the correct manner. Post your code.
Edit: posted a minute too late...
hi, this javascript works perfect in IExplorer but not in firefox. I get error in line
document.getElementById("supplier_no").value= values_array[0]; .... shows in firefox error console
Error: getElementById returns null. what can be the problem? please help - var winName; //variable for the popup window
-
var g_return_destination = null ; //variable to track where the data gets sent back to.
-
-
-
// Set the value in the original pages text box.
-
function f_set_home_value( as_Value )
-
{
-
if (document.getElementById(g_return_destination[0]).name == "netbank_supplier_name_info" )
-
{
-
//clear the old values
-
for (selnum = 1; selnum <= 5; selnum++)
-
{
-
document.getElementById("expense_account"+selnum).value = "";
-
document.getElementById("expense_account_name"+selnum).value = "";
-
document.getElementById("expense_vat_flag"+selnum).value = "off";
-
document.getElementById("expense_vat_flag"+selnum).checked = "";
-
document.getElementById("expense_vat_amount"+selnum).value = "";
-
document.getElementById("expense_vat_code"+selnum).value = "";
-
document.getElementById("expense_period"+selnum).value = "";
-
document.getElementById("expense_date"+selnum).value = "";
-
if (selnum!=1) {//these are sometimes defaulted in, and in any case you will always have line1
-
document.getElementById("expense_more_dept"+selnum).value = "";
-
document.getElementById("expense_more_prj"+selnum).value = "";
-
document.getElementById("expense_more_subj"+selnum).value = "";
-
}
-
document.getElementById("expense_amount"+selnum).value = "";
-
}
-
var values_array = as_Value[0].split("!");
-
document.getElementById("supplier_no").value= values_array[0];
-
document.getElementById("supplier_bankAccount_no").value= values_array[1];
-
str = values_array[2] ;
-
str = str.split(";sp;").join(" ");
-
document.getElementById("default_expense_account").value= str;
-
document.getElementById("expense_account1").value= str;
-
document.getElementById("expense_more_sok1").disabled= false;
-
str = values_array[3] ;
-
str = str.split(";sp;").join(" ");
-
document.getElementById("payment_term").value= str;
-
strPeriod = calcPeriod(str,document.getElementById("due_date").value);
-
document.getElementById("expense_period1").value = (strPeriod);
-
strExpenseDate = calcExpenseDate(str,document.getElementById("due_date").value);
-
document.getElementById("expense_date1").value = (strExpenseDate);
-
str = values_array[4] ;
-
str = str.split(";sp;").join(" ");
-
document.getElementById("expense_account_name1").value= str;
-
str = values_array[5] ;
-
str = str.split(";sp;").join(" ");
-
document.getElementById("expense_vat_code1").value= str;
-
if (str == 0) {
-
document.getElementById("expense_vat_flag1").checked= '';
-
document.getElementById("expense_vat_flag1").disabled= true;
-
}else{
-
document.getElementById("expense_vat_flag1").checked= 'yes';
-
document.getElementById("expense_vat_flag1").value= 'on';
-
document.getElementById("expense_vat_flag1").disabled= false;
-
}
-
str = values_array[6] ;
-
str = str.split(";sp;").join(" ");
-
document.getElementById("supplier_name").value= str;
-
var str = values_array[7];
-
str = str.split(";sp;").join(" ");
-
str = str.split("&cr;").join("\r");
-
document.getElementById("netbank_supplier_name_info").value= str;
-
strx = justNumberNF(document.getElementById("amount").value);
-
document.all["expense_vat_amount1"].value = NetbankToDollarsAndCents(strx * (24/124)) ;
-
document.getElementById("amount").value=NetbankToDollarsAndCents(strx);
-
document.getElementById("expense_amount1").value = document.getElementById("amount").value;
-
-
document.getElementById("expense_amount2").value = '';
-
document.getElementById("expense_account2").value= '';
-
//document.getElementById("expense_vat_flag2").value= '';
-
document.getElementById("expense_vat_amount2").value= '';
-
document.getElementById("expense_amount3").value = '';
-
document.getElementById("expense_account3").value= '';
-
//.getElementById("expense_vat_flag3").value= '';
-
document.getElementById("expense_vat_amount3").value= '';
-
document.getElementById("expense_amount4").value = '';
-
document.getElementById("expense_account4").value= '';
-
//document.getElementById("expense_vat_flag4").value= '';
-
document.getElementById("expense_vat_amount4").value= '';
-
document.getElementById("expense_amount5").value = '';
-
document.getElementById("expense_account5").value= '';
-
//document.getElementById("expense_vat_flag5").value= '';
-
document.getElementById("expense_vat_amount5").value= '';
-
str = values_array[8] ;
-
str = str.split(";sp;").join(" ");
-
if (str=="2"){
-
document.frmName.ButtonSelPeriodisering1.disabled=false;
-
document.frmName.ButtonSelPeriodisering1.click();
-
}
-
winName.close();
-
}
-
}
-
-
//Pass Data Back to original window
-
function f_popup_return(as_Value)
-
{
-
var l_return = new Array(1);
-
l_return[0] = as_Value;
-
-
f_set_home_value(l_return);
-
}
-
-
function justNumberNF(val){
-
val = (val==null) ? 0 : val;
-
// check if a number, otherwise try taking out non-number characters.
-
if (isNaN(val)) {
-
var newVal = parseFloat(val.replace(/[^\d\.\-]/g, '.'));
-
// check if still not a number. Might be undefined, '', etc., so just replace with 0.
-
return (isNaN(newVal) ? 0 : newVal);
-
}
-
// return 0 in place of infinite numbers.
-
else if (!isFinite(val)) { return 0; }
-
-
return val;
-
};
-
function NetbankToDollarsAndCents(n) {
-
var s = "" + Math.round(n * 100) / 100 ;
-
var i = s.indexOf('.') ;
-
if (i < 0) {return s + ",00" } ;
-
var t = s.substring(0, i + 1) + s.substring(i + 1, i + 3) ;
-
if (i + 2 == s.length) {t += "0"} ;
-
return t.replace('.',',') ;
-
}
I do really don't like to view codes.
gits 5,390
Expert Mod 4TB
@leendon023: what should that help?
to the question above:
does the page has an element with an id 'supplier_no'?
kind regards
Sign in to post your reply or Sign up for a free account.
Similar topics
by: tshad |
last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an
asp.net problem or a javascript problem.
I have a page that was originally created from a program I found on the net...
|
by: Derek Erb |
last post by:
I am banging my head against the wall with this one. The following
code snippets work perfectly fine in MSIE6. But produce an error in
Firefox and do not work at all.
BROWSER.HTM
<HTML>
.......
|
by: lkrubner |
last post by:
We are working on a website that is here:
http://www.lauradenyes.com/
The site was working till I put up an .htaccess file that was suppose
to redirect all html files to the PHP parser. The...
|
by: David Blickstein |
last post by:
I have some XML documents that I want to open in a web browser and be
automatically translated to HTML via XSLT. I'm using an xml-stylesheet
processing command in a file called "girml.xml".
...
|
by: KBuser |
last post by:
I recently developed an internal website with various queries against
our SQL server. I added buttons with Response.Redirect. These buttons
do not work with Internet Explorer, however when using...
|
by: puja |
last post by:
hi all,
I have an asp.net website where am including .css file dynamically on page
load event. For diff users, there is diff CSS file. So after user logs in, I
am setting CSS href on page load....
|
by: entfred |
last post by:
I have the following line of html:
 1234  abc  yow
In Internet Explorer 6.0, the columns look ok using the above html:
1234 abcd ...
|
by: Arodicus |
last post by:
I have a static class method, MyObject.MySub.MyMethod(), which points to a handler in a Flash SWF (but I think that's inconsequential). In reality, the path is a lot longer, so I'd like to make a...
|
by: Stever1975 |
last post by:
I'm working on something similiar to a shopping cart item page. There
is a table of items. Each item has an image, a textbox for the qty
and an image for the add button.
When the add image is...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| | |