javascript working on mozilla firefox but not on IE 6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • itgaurav198
    New Member
    • Oct 2007
    • 41

    javascript working on mozilla firefox but not on IE 6

    Hi,

    I have the following script

    Code:
    function submitForm1()
    {
       document.forms[0].action="SearchRecords";
       document.forms[0].submit();
    }
    [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
  • itgaurav198
    New Member
    • Oct 2007
    • 41

    #2
    javascript working on mozilla firefox but not on IE 6

    Hi,

    I have the following script


    [CODE=javascript]function submitForm1()
    {
    document.forms[0].action="Search Records";
    document.forms[0].submit();
    }
    [/CODE]


    [HTML]<select name="l" onchange="submi tForm1();">[/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
    Last edited by gits; Oct 29 '07, 10:28 AM. Reason: added code tags

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by itgaurav198
      Hi,

      I have the following script

      Code:
      function submitForm1()
      {
         document.forms[0].action="SearchRecords";
         document.forms[0].submit();
      }
      [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
      Java != Javascript

      Moved to Javascript forum

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        threads merged ... since they cover the same topic/question ...

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          So what happens in IE? Any errors?

          Comment

          • itgaurav198
            New Member
            • Oct 2007
            • 41

            #6
            Originally posted by acoder
            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

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              Originally posted by itgaurav198
              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?

              Comment

              • itgaurav198
                New Member
                • Oct 2007
                • 41

                #8
                Originally posted by acoder
                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

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  Can you post the rest of the code or a link? If the code is too long, post the relevant parts.

                  Comment

                  • itgaurav198
                    New Member
                    • Oct 2007
                    • 41

                    #10
                    Originally posted by acoder
                    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

                    Comment

                    • rizwan6feb
                      New Member
                      • Jul 2007
                      • 108

                      #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:

                      Code:
                      document.forms[0].action="SearchRecords";
                      document.forms[0].submit();
                      which is causing the form not to submit. Try using alert functions to debug the statements above the form submission code

                      Comment

                      • itgaurav198
                        New Member
                        • Oct 2007
                        • 41

                        #12
                        Originally posted by rizwan6feb
                        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:

                        Code:
                        document.forms[0].action="SearchRecords";
                        document.forms[0].submit();
                        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

                        Code:
                        function submitForm1()
                        {
                        alert("hvgfjh");
                           document.forms[0].action="SearchRecords";
                           document.forms[0].submit();
                        }
                        Code:
                        function submitForm1()
                        {
                           document.forms[0].action="SearchRecords";
                        alert("hvgfjh");
                           document.forms[0].submit();
                        }
                        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

                        Comment

                        • itgaurav198
                          New Member
                          • Oct 2007
                          • 41

                          #13
                          Originally posted by itgaurav198
                          Hi,
                          I have tried both of the following

                          Code:
                          function submitForm1()
                          {
                          alert("hvgfjh");
                             document.forms[0].action="SearchRecords";
                             document.forms[0].submit();
                          }
                          Code:
                          function submitForm1()
                          {
                             document.forms[0].action="SearchRecords";
                          alert("hvgfjh");
                             document.forms[0].submit();
                          }
                          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

                          Comment

                          • itgaurav198
                            New Member
                            • Oct 2007
                            • 41

                            #14
                            Originally posted by itgaurav198
                            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

                            Comment

                            • itgaurav198
                              New Member
                              • Oct 2007
                              • 41

                              #15
                              Originally posted by itgaurav198
                              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
                              Code:
                              <%@ 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")%>><%=request.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).toString()%></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=action value="Reset"></td>
                              	        </tr>
                              	    </table>
                              	    
                              	</form>
                              </center>
                              </body>
                              </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.

                              Comment

                              Working...