473,809 Members | 2,775 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript working on mozilla firefox but not on IE 6

41 New Member
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="submi tForm1();">[/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
26 3381
rizwan6feb
108 New Member
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
itgaurav198
41 New Member
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
itgaurav198
41 New Member
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
itgaurav198
41 New Member
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
itgaurav198
41 New Member
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="Search Records"; 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="Search Records"; it neither shows alert box now submits the form to SearchRecords servlet.
Oct 30 '07 #15
acoder
16,027 Recognized Expert Moderator MVP
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
itgaurav198
41 New Member
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="Search Records".

Thanks
Oct 31 '07 #17
itgaurav198
41 New Member
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 Recognized Expert Moderator MVP
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 "SearchReco rds" anymore.
Oct 31 '07 #19
itgaurav198
41 New Member
Now you don't have that submit button named "action" anymore, so it doesn't 'think' that the action object is being set to "SearchReco rds" 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.ut il.ArrayList"%>
<%@ page import="javax.s ervlet.*"%>
<%@ page import="javax.s ervlet.http.*"% >

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

function submitForm1()
{

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

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

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

<%
ArrayList al=(ArrayList)s ession.getAttri bute("str_");
%>


</head>



<body bgcolor="fuschi a">



<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"><f ont size=5>Last Name</font></td>
<td>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;<inpu t type=text name="sn" value="<%=reque st.getAttribute ("lname") %>"></td>
</tr>

<tr>
<td align="left"><f ont size=5>FullName </font></td>
<td>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;<inpu t type=text name="cn" value="<%=reque st.getAttribute ("fname")%>"><t d>
</tr>

<tr>
<td align="left"><f ont size=5>Location </font></td>
<td>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;
<select name="l" onchange="submi tForm1();">
<%if(request.ge tAttribute("loc ation")!=null)% >
<Option value="<%=reque st.getAttribute ("location")%>> <%=request.getA ttribute("locat ion")%></Option>
<Option value="Chandiga rh">Chandigar h</Option>
<Option value="Pune">Pu ne</Option>
<Option value="Banglore ">Banglore</Option>
</select>
</td>
</tr>

<tr>
<td align="left"><f ont 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.ge t(i).toString() %>"><%=al.get(i ).toString()%></Option>
<%}%>
</select>
</TD>
<%}
catch(Exception e)
{
e.printStackTra ce();
}%>
</tr>

<tr>
<td align="right">< input type=submit name=action value="Submit" onclick="submit Form2();"></td>
<td align="left">&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;<input type=reset name="submitBut ton" 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="Search Records"; it shows neither alert nor submits the form and if i use alert before document.forms[0].action="Search Records"; 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="Search Records";)

Thanks
Oct 31 '07 #20

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

Similar topics

8
3681
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
7
9623
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 language="JavaScript"> var cntlName; var eleTarget = document.getElementById('hiding'); function showOrHide(){
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9601
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10637
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10115
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9199
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7660
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.