473,405 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Javascript code not working in IE but working in Mozilla firefox

Hi,

I am using this code to read the option values from a select option. I am getting the reference of that select option in arg1. Its working fine with mozilla firefox but not with Internet Explorer. It gives the lenth but failing to read the arguments(Shown in bold). It gives the alert Internet Explorer 4 for IE and Netscape 5 for Mozilla firefox for the alert in line 4. Please Suggest as soon as possible how I can read the values of the select option for IE. I shall be thankful.

function custom(arg,arg1)
if (arg == "custom")
{

var brow=((navigator.appName) + (parseInt(navigator.appVersion)));
alert("Browser" + brow);
var length = arg1.options.length;
alert("length" + length);
var str1 = "";

for(var i = 1;i < length-1; i++ )
{
str1 = str1 + arg1.options[i].value + ";" ;
}

alert(str1);
var url = "/futopt/globalrec-ajaysoni/webapp/jsp/welcome.jsp";
url = url + "?str=" + str1;
window.open(url,'welcome','width=300,height=200');
}
}
Dec 1 '06 #1
1 3128
I don't understand what you're trying to do, but you're missing a "{" right after custom(arg,arg1). It will run in IE now. You are adding all values starting with the second and leaving the last one. Are you sure that is what you want?

If you want the selected value all you have to do is:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.     <head>
  3.         <script language="javascript">
  4.             function custom(arg,arg1) {
  5.                 if (arg == "custom") {
  6.                     str1 = arg1.value;
  7.  
  8.                     var url = "/futopt/globalrec-ajaysoni/webapp/jsp/welcome.jsp";
  9.                     url = url + "?str=" + str1;
  10.                     window.open(url,'welcome','width=300,height=200'); 
  11.                 }
  12.             }
  13.         </script>
  14.     </head>
  15.     <body>
  16.         <select id="s_thing" onchange="custom('custom',this)">
  17.             <option value="One">One</optiin>
  18.             <option value="Two">Two</option>
  19.             <option value="Three">Three</optiin>
  20.         </select>
  21.     <body>
  22. </html>
Dec 4 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
7
by: Coder | last post by:
Hi I have the following code in java script, it is not giving proper output in FIREFOX but running fine in IE... can anybody help me out to make this run in FIREFOX . <script...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.