473,387 Members | 1,502 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,387 software developers and data experts.

javascript working on mozilla firefox but not on IE 6

Hi,

I have the following script

Expand|Select|Wrap|Line Numbers
  1. function submitForm1()
  2. {
  3.    document.forms[0].action="SearchRecords";
  4.    document.forms[0].submit();
  5. }
[HTML]<select name="l" onchange="submitForm1();">[/HTML]

This script is working on firefox but not in IE6.
Can anybody tell me why this is happening and the alternative solution to perform the same function.

Thanks
Oct 29 '07 #1
26 3324
Hi,

I have the following script


Expand|Select|Wrap|Line Numbers
  1. function submitForm1()
  2. {
  3.    document.forms[0].action="SearchRecords";
  4.    document.forms[0].submit();
  5. }
  6.  

[HTML]<select name="l" onchange="submitForm1();">[/code][/HTML]


This script is working on firefox but not in IE6.
Can anybody tell me why this is happening and the alternative solution to perform the same function.

Thanks
Oct 29 '07 #2
r035198x
13,262 8TB
Hi,

I have the following script

Expand|Select|Wrap|Line Numbers
  1. function submitForm1()
  2. {
  3.    document.forms[0].action="SearchRecords";
  4.    document.forms[0].submit();
  5. }
[HTML]<select name="l" onchange="submitForm1();">[/HTML]

This script is working on firefox but not in IE6.
Can anybody tell me why this is happening and the alternative solution to perform the same function.

Thanks
Java != Javascript

Moved to Javascript forum
Oct 29 '07 #3
gits
5,390 Expert Mod 4TB
threads merged ... since they cover the same topic/question ...
Oct 29 '07 #4
acoder
16,027 Expert Mod 8TB
So what happens in IE? Any errors?
Oct 29 '07 #5
So what happens in IE? Any errors?
Hi,
There is neither any response nor any error means it does not call SearchRecords at all.

Thanx
Oct 30 '07 #6
acoder
16,027 Expert Mod 8TB
There is neither any response nor any error means it does not call SearchRecords at all.
Is 'SearchRecords' a valid server file?

You're using forms[0]. Is there only one form in the page?
Oct 30 '07 #7
Is 'SearchRecords' a valid server file?

You're using forms[0]. Is there only one form in the page?
Hi,

There is only one form and also SearchRecords is valid after all this is working on Firefox.
Is it possible that we have to make some changes in settings of IE?If yes, what will be those settings.

Thanks
Oct 30 '07 #8
acoder
16,027 Expert Mod 8TB
Can you post the rest of the code or a link? If the code is too long, post the relevant parts.
Oct 30 '07 #9
Can you post the rest of the code or a link? If the code is too long, post the relevant parts.
Hi,
Thax for ur consideration. but I think the code in original post is sufficient to find the error. In this I have one dropdown and based on that I call the javascript function that sets the action attribute for the form and submits it to that servlet.

Thanks
Oct 30 '07 #10
rizwan6feb
108 100+
There is nothing wrong with the original code, even if IE6 is being used. There can be error in the code above these two statements:

Expand|Select|Wrap|Line Numbers
  1. document.forms[0].action="SearchRecords";
  2. document.forms[0].submit();
  3.  
which is causing the form not to submit. Try using alert functions to debug the statements above the form submission code
Oct 30 '07 #11
There is nothing wrong with the original code, even if IE6 is being used. There can be error in the code above these two statements:

Expand|Select|Wrap|Line Numbers
  1. document.forms[0].action="SearchRecords";
  2. document.forms[0].submit();
  3.  
which is causing the form not to submit. Try using alert functions to debug the statements above the form submission code
Hi,
I have tried both of the following

Expand|Select|Wrap|Line Numbers
  1. function submitForm1()
  2. {
  3. alert("hvgfjh");
  4.    document.forms[0].action="SearchRecords";
  5.    document.forms[0].submit();
  6. }
Expand|Select|Wrap|Line Numbers
  1. function submitForm1()
  2. {
  3.    document.forms[0].action="SearchRecords";
  4. alert("hvgfjh");
  5.    document.forms[0].submit();
  6. }
In IE6
In first one the alert box works but in second no alert box appears.
In IE7
But both are working on IE7

Thanks
Oct 30 '07 #12
Hi,
I have tried both of the following

Expand|Select|Wrap|Line Numbers
  1. function submitForm1()
  2. {
  3. alert("hvgfjh");
  4.    document.forms[0].action="SearchRecords";
  5.    document.forms[0].submit();
  6. }
Expand|Select|Wrap|Line Numbers
  1. function submitForm1()
  2. {
  3.    document.forms[0].action="SearchRecords";
  4. alert("hvgfjh");
  5.    document.forms[0].submit();
  6. }
In IE6
In first one the alert box works but in second no alert box appears.
In IE7
But both are working on IE7

Thanks
Hi,

Its working in case of radiobutton but not on onchange event of dropdown.

Thanks
Oct 30 '07 #13
Hi,

Its working in case of radiobutton but not on onchange event of dropdown.

Thanks
Hi,

Sorry for the previous post.
Please ignore the previous reply because it works for both radiobutton and dropdown in IE 7 but not with IE 6.

Thanks
Oct 30 '07 #14
Hi,

Sorry for the previous post.
Please ignore the previous reply because it works for both radiobutton and dropdown in IE 7 but not with IE 6.

Thanks
Hi,

The complete code is as below
Expand|Select|Wrap|Line Numbers
  1. <%@ page import="java.util.ArrayList"%>
  2. <%@ page import="javax.servlet.*"%>
  3. <%@ page import="javax.servlet.http.*"%>
  4.  
  5. <html>
  6. <head>
  7. <title> Form </title>
  8. <script language="javascript" type="text/javascript">
  9.  
  10. function submitForm1()
  11. {
  12.  
  13.    document.forms[0].action="SearchRecords";
  14.    alert("fghfhfhf");
  15.  
  16.    document.forms[0].submit();
  17. }
  18.  
  19. function submitForm2()
  20. {
  21. document.forms[0].action="Search";
  22. document.forms[0].submit();
  23. }
  24. </script>
  25.  
  26. <%
  27. ArrayList al=(ArrayList)session.getAttribute("str_");
  28. %>
  29.  
  30.  
  31. </head>
  32.  
  33.  
  34.  
  35. <body bgcolor="fuschia">
  36.  
  37.  
  38.  
  39. <center>
  40.  
  41.     <font size=7 color="red"> Please Enter the following information: </font>
  42.        <form name="form1" method="POST">
  43.  
  44.            <table cellspacing="2" cellpadding="2" border="0">
  45.                <tr>
  46.            <td><input type="hidden" name="role" id="role"></td>
  47.             </tr>
  48.  
  49.         <tr>
  50.         <td align="left"><font size=5>Last Name</font></td>
  51.         <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=text name="sn" value="<%=request.getAttribute("lname") %>"></td>
  52.         </tr>
  53.  
  54.         <tr>
  55.         <td align="left"><font size=5>FullName</font></td>
  56.         <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=text name="cn" value="<%=request.getAttribute("fname")%>"><td>
  57.         </tr>
  58.  
  59.         <tr>
  60.         <td align="left"><font size=5>Location</font></td>
  61.         <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  62.         <select name="l" onchange="submitForm1();">
  63.         <%if(request.getAttribute("location")!=null)%>
  64.         <Option value="<%=request.getAttribute("location")%>><%=request.getAttribute("location")%></Option>
  65.         <Option value="Chandigarh">Chandigarh</Option>
  66.         <Option value="Pune">Pune</Option>
  67.         <Option value="Banglore">Banglore</Option>
  68.         </select>
  69.         </td>
  70.         </tr>
  71.  
  72.            <tr>
  73.            <td align="left"><font size=5>Role</font></td>
  74.            <%try{%>
  75.            <TD>
  76.             <select name="erRoles" id="erRoles"> 
  77.             <option>- - - - - - -</option>
  78.             <%for(int i=0;i<al.size();i++){%>
  79.             <Option value="<%=al.get(i).toString()%>"><%=al.get(i).toString()%></Option>
  80.             <%}%>
  81.             </select>
  82.             </TD>        
  83.             <%}
  84.             catch(Exception e)
  85.             {
  86.               e.printStackTrace();
  87.              }%>
  88.             </tr> 
  89.  
  90.             <tr>
  91.             <td align="right"><input type=submit name=action value="Submit" onclick="submitForm2();"></td>
  92.             <td align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=reset name=action value="Reset"></td>
  93.             </tr>
  94.         </table>
  95.  
  96.     </form>
  97. </center>
  98. </body>
  99. </html>
In IE 6
In submitForm1() if I use alert before document.forms[0].action="SearchRecords"; then it only shows the alert box but do not submit the form to SearchRecords servlet and if i use it after document.forms[0].action="SearchRecords"; it neither shows alert box now submits the form to SearchRecords servlet.
Oct 30 '07 #15
acoder
16,027 Expert Mod 8TB
Hi,
Thax for ur consideration. but I think the code in original post is sufficient to find the error.
No it wasn't. I've spotted the error by looking at your full code.

You've named your submit button "action" which is causing problems when setting the action property. Rename it to something else, even 'action1' will do.
Oct 30 '07 #16
No it wasn't. I've spotted the error by looking at your full code.

You've named your submit button "action" which is causing problems when setting the action property. Rename it to something else, even 'action1' will do.
Hi,

The same situation even after changing the name of button.
When I change the dropdown list value the page shows an error on left bottom side of Browser and shows that "Object doesn't support this property or method" for document.forms[0].action="SearchRecords".

Thanks
Oct 31 '07 #17
Hi,
The following code works properly
Expand|Select|Wrap|Line Numbers
  1. <%@ page import="javax.servlet.*"%>
  2. <%@ page import="javax.servlet.http.*"%>
  3.  
  4. <html>
  5. <head>
  6. <title> Form </title>
  7. <script language="javascript" type="text/javascript">
  8.  
  9. function submitForm1()
  10. {
  11.  
  12.    document.forms[0].action="SearchRecords";
  13.    alert("hjgjh");
  14.  
  15.    document.forms[0].submit();
  16. }
  17. </script>
  18.  
  19. </head>
  20.  
  21.  
  22.  
  23. <body bgcolor="fuschia">
  24. <center>
  25.  
  26.     <font size=7 color="red"> Please Enter the following information: </font>
  27.        <form name="form1" method="POST">
  28.            <table cellspacing="2" cellpadding="2" border="0">            
  29.         <tr>
  30.         <td align="left"><font size=5>Location</font></td>
  31.         <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  32.         <select name="l" onchange="submitForm1();">
  33.         <Option value="Chandigarh" selected="selected">Chandigarh</Option>
  34.         <Option value="Pune">Pune</Option>
  35.         <Option value="Banglore">Banglore</Option>
  36.         </select>
  37.         </td>
  38.         </tr>
  39.         </table>
  40.  
  41.     </form>
  42. </center>
  43. </body>
  44. </html>
Then why the code posted before doesn't work in IE.
Please reply it is really urgent and important.
Thanx
Oct 31 '07 #18
acoder
16,027 Expert Mod 8TB
Then why the code posted before doesn't work in IE.
Now you don't have that submit button named "action" anymore, so it doesn't 'think' that the action object is being set to "SearchRecords" anymore.
Oct 31 '07 #19
Now you don't have that submit button named "action" anymore, so it doesn't 'think' that the action object is being set to "SearchRecords" anymore.
Hi,
I just want to call the submitForm1() function on onchange event of location dropdown and want to submit the form to SearchRecords in the code below:(Please see the bold part in code)
[HTML]<%@ page import="java.util.ArrayList"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>

<html>
<head>
<title> Form </title>
<script language="javascript" type="text/javascript">

function submitForm1()
{

document.forms[0].action="SearchRecords";
alert("fghfhfhf");

document.forms[0].submit();
}

function submitForm2()
{
document.forms[0].action="Search";
document.forms[0].submit();
}
</script>

<%
ArrayList al=(ArrayList)session.getAttribute("str_");
%>


</head>



<body bgcolor="fuschia">



<center>

<font size=7 color="red"> Please Enter the following information: </font>
<form name="form1" method="POST">

<table cellspacing="2" cellpadding="2" border="0">
<tr>
<td><input type="hidden" name="role" id="role"></td>
</tr>

<tr>
<td align="left"><font size=5>Last Name</font></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=text name="sn" value="<%=request.getAttribute("lname") %>"></td>
</tr>

<tr>
<td align="left"><font size=5>FullName</font></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=text name="cn" value="<%=request.getAttribute("fname")%>"><td>
</tr>

<tr>
<td align="left"><font size=5>Location</font></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<select name="l" onchange="submitForm1();">
<%if(request.getAttribute("location")!=null)%>
<Option value="<%=request.getAttribute("location")%>><%=re quest.getAttribute("location")%></Option>
<Option value="Chandigarh">Chandigarh</Option>
<Option value="Pune">Pune</Option>
<Option value="Banglore">Banglore</Option>
</select>
</td>
</tr>

<tr>
<td align="left"><font size=5>Role</font></td>
<%try{%>
<TD>
<select name="erRoles" id="erRoles">
<option>- - - - - - -</option>
<%for(int i=0;i<al.size();i++){%>
<Option value="<%=al.get(i).toString()%>"><%=al.get(i).toS tring()%></Option>
<%}%>
</select>
</TD>
<%}
catch(Exception e)
{
e.printStackTrace();
}%>
</tr>

<tr>
<td align="right"><input type=submit name=action value="Submit" onclick="submitForm2();"></td>
<td align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;< input type=reset name="submitButton" value="Reset"></td>
</tr>
</table>

</form>
</center>
</body>
</html>[/HTML]

But it warks fine in Firefox and not in IE.if I use alert after document.forms[0].action="SearchRecords"; it shows neither alert nor submits the form and if i use alert before document.forms[0].action="SearchRecords"; it shows alert box but don't submit the form. It also shows a Browser warning on bottom left corner Object doesn't support Line 13(i.e.document.forms[0].action="SearchRecords";)

Thanks
Oct 31 '07 #20
acoder
16,027 Expert Mod 8TB
As I told you before, you have to change the name of the submit button. IE is very easily confused!

On line 89, you have:[HTML]<input type=submit name=action value="Submit" onclick="submitForm2();">[/HTML] Change "action" to "action1" or some other name that is not the name of a method or attribute.
Oct 31 '07 #21
As I told you before, you have to change the name of the submit button. IE is very easily confused!

On line 89, you have:[HTML]<input type=submit name=action value="Submit" onclick="submitForm2();">[/HTML] Change "action" to "action1" or some other name that is not the name of a method or attribute.
Hi,
I have tried it but still its not working

Thanks
Oct 31 '07 #22
acoder
16,027 Expert Mod 8TB
Hi,
I have tried it but still its not working

Thanks
So what happens now? Any errors? Can you also post your revised code?
Oct 31 '07 #23
So what happens now? Any errors? Can you also post your revised code?
Hi,

Revised code as below

Expand|Select|Wrap|Line Numbers
  1. <%@ page import="java.util.ArrayList"%>
  2. <%@ page import="javax.servlet.*"%>
  3. <%@ page import="javax.servlet.http.*"%>
  4.  
  5. <html>
  6. <head>
  7. <title> Form </title>
  8. <script language="javascript" type="text/javascript">
  9.  
  10. function submitForm1()
  11. {
  12.  
  13.    document.forms[0].action="SearchRecords";
  14.    alert("fghfhfhf");
  15.  
  16.    document.forms[0].submit();
  17. function submitForm2()
  18. {
  19. document.forms[0].action="Search";
  20. document.forms[0].submit();
  21. }
  22. </script>
  23.  
  24. <%
  25. ArrayList al=(ArrayList)session.getAttribute("str_");
  26. %>
  27.  
  28.  
  29. </head>
  30.  
  31.  
  32.  
  33. <body bgcolor="fuschia">
  34.  
  35.  
  36.  
  37. <center>
  38.  
  39.     <font size=7 color="red"> Please Enter the following information: </font>
  40.        <form name="form1" method="POST">
  41.  
  42.            <table cellspacing="2" cellpadding="2" border="0">
  43.             <tr>
  44.         <td><input type="hidden" name="role" id="role"></td>
  45.             </tr>
  46.  
  47.         <tr>
  48.         <td align="left"><font size=5>Last Name</font></td>
  49.         <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=text name="sn" value="<%=request.getAttribute("lname") %>"></td>
  50.         </tr>
  51.  
  52.         <tr>
  53.         <td align="left"><font size=5>FullName</font></td>
  54.         <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=text name="cn" value="<%=request.getAttribute("fname")%>"><td>
  55.         </tr>
  56.  
  57.         <tr>
  58.         <td align="left"><font size=5>Location</font></td>
  59.         <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  60.         <select name="l" onchange="submitForm1();">
  61.         <%if(request.getAttribute("location")!=null)%>
  62.         <Option value="<%=request.getAttribute("location")%>><%=request.getAttribute("location")%></Option>
  63.         <Option value="Chandigarh">Chandigarh</Option>
  64.         <Option value="Pune">Pune</Option>
  65.         <Option value="Banglore">Banglore</Option>
  66.         </select>        </td>
  67.         </tr>
  68.  
  69.         <tr>
  70.         <td align="left"><font size=5>Role</font></td>
  71.         <%try{%>
  72.         <TD>
  73.             <select name="erRoles" id="erRoles"> 
  74.             <option>- - - - - - -</option>
  75.             <%for(int i=0;i<al.size();i++){%>
  76.             <Option value="<%=al.get(i).toString()%>"><%=al.get(i).toString()%></Option>
  77.             <%}%>
  78.             </select>
  79.             </TD>      
  80.             <%}
  81.             catch(Exception e)
  82.             {
  83.               e.printStackTrace();
  84.              }%>
  85.             </tr> 
  86.  
  87.             <tr>
  88.             <td align="right"><input type=submit name=action value="Submit" onclick="submitForm2();"></td>
  89.             <td align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=reset name="submitButton" value="Reset"></td>
  90.             </tr>
  91.         </table>
  92.  
  93.     </form>
  94. </center>
  95. </body>
  96. </html>
The same situation ie when i use alert box before setting document.forms[0].action="SearchRecords" it shows the alert bax on onchange event but don't submit the code but when i place alert before document.forms[0].action="SearchRecords" neither it shows alert box nor it submits the form.

Even in both the cases it shows a warning (that browser shows when page loads) and the details are

Line: 12
Char: 4
Error: Object doesn't support this property or Method
Code: 0
URL: ...........................


Thanks
Oct 31 '07 #24
acoder
16,027 Expert Mod 8TB
You've not actually made the change.

Change line 89 to:
[HTML]<td align="right"><input type=submit name="action1" value="Submit" onclick="submitForm2();"></td>[/HTML]
Oct 31 '07 #25
You've not actually made the change.

Change line 89 to:
[HTML]<td align="right"><input type=submit name="action1" value="Submit" onclick="submitForm2();"></td>[/HTML]
Hi,
Sorry, actually i have changed the one button code and not the other now this is working fine.

But still I am not clear why the same (wrong) code was working fine on Firefox.
Can you tell me the reason or some link where i can find out these differences between firefox and IE.
Thanks
Thanks a lot
Oct 31 '07 #26
acoder
16,027 Expert Mod 8TB
The situation is same as described in above post.
Now you've renamed the reset button to "action". Use a different name.
Oct 31 '07 #27

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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.