Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form not invoked with IE and onclick script but works with mozilla

    I have a page invoked under a nested frameset. The page contains a form that uses a table for formatting. When the submit button is clicked the onclick event is intened to do a few field formatting checks andthen set the page to be displayed after/while the form is processed. However I can get this working only under Mozilla Firefox and not IE5.
    I have experimented with bypassing scripts altogether, setting the page name in the parent.location.href , parent.form[0].form[1].location.href, location.href, building another script to alter these to the full path name of the page required. All to no avail and much nashing of teeth.
    I currently am using
    <input type="submit" value="Save" name="b1" onclick="javascript:
    top.location.href = 'file:///C:/WEB%20WORK/thesolotraveller_workcopy/TestDoorJam/Loginframeindex.html' ; " >

    this successfully sets the new page (actually rewrites the current one I think?). This rewrites or updates the page happily with IE5 or FireFox but the form only suceeds with FireFox.
    If I remove the onclick altogether the form is successful in both browsers?
    This is as good a handle as I have been able to get one the problem so far. Any help, suggestions, or insights would be greatly appreciated.

    thank you ............Walter
    Last edited by Walter982247; 12-24-2004 at 09:28 AM. Reason: incomplete

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Can we see the code?

  • #3
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Absolutely

    I can paste it into this space (is there a better place to put it?) It's not too pretty I have been fiddling with it a lot and it currently has the remnants of bypassing scripts in turn,but I'm sure you can see all that better than I can.

    ==============================================================
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    
    <html>
    <head>
    	<title>Basic script </title>
    	
    		<script language="javascript" type="text/javascript">
    		// all scripts present but none invoked.
    		// onclick does set the new location thereby repainting the entire
    		// window but this only allows the form to work with mozilla but not ie !!!
    		// Much muttering under breath again !!!
    		// the form without the onclick will work correctly on ie and mozilla
    		// but no new page or frame is set hence path not found or page not found 
    		// results !!! chkpt1 
    		 
    //<!--
    	  
    
    	
    	function setInitialStuff()
        {
          <!-- document.newuser.tokenuser_fieldc.value='wr982247@optusnet.com.au' -->
          document.newuser.tokenuser_fielda.focus();
        }
    	function setValues_dummy() {
    			 var fred = "fred" ;
    			 alert("dummy set Values invoked " );
    	}
    	
    	function setValues() {
    		/*alert("we have started setvalues() ")*/
    		var new_loc = "preamble3.html" ;  <!-- eyecatch bad return from setloc --> 
            if( document.forms[0].elements[0].value != "" &&
                document.forms[0].elements[1].value != "" &&
                document.forms[0].elements[2].value != "") {
            	
                if /*(validateEmail(document.forms[0].elements[2].value)) */ (true) {
                    var strCookie = document.forms[0].elements[0].value + "|" +
                                    document.forms[0].elements[1].value + "|" +
                                    document.forms[0].elements[2].value;
                 /* setCookie("user",strCookie,"","/"); */
    			
    			 new_loc = setLocation();
    			 
    			 alert("new_loc is " + new_loc);
    			 
    			 top.location.href = new_loc ; 
    							
    			/*	parent.location.href = 'Preamble1.html' ;
    				
    				/*parent.location.href = "Loginframeindex.html";*/
    				
    				/*parent.location.href='Loginframeindex.html';*/    
    			/* alert("locations on return from scripts = " ) ; */
    			alert("parent.location.href = " + parent.location.href);
    			alert("location.href = " + location.href);
    			alert("top.location.href = " + top.location.href);
                    /*window.location("Loginframeindex.html"); */  
    				
    				return true;
    				       
                }else {
    				   alert("You must submit a valid Email.");
    				   return false;
    				   }                                                                                                                                                                                                             
            }
            else {
    			  alert("Please fill in your Name and Email Address");
    			  return false;
    			  }
    		/*alert("should be at the end of all setvalues() tests ") ;  */
    		
    	    return true;
        }
    
        function validateEmail(email) {
            var address = new String(email);
            if (address == "") return false;     
            invalidChars = " /:,;";   
                for (i=0; i<invalidChars.length; i++) {
                badChar = invalidChars.charAt(i);
                if (address.indexOf(badChar, 0) > -1) return false;  
            }   
            atPos = address.indexOf("@",1); 
            if (address.indexOf("@",0) == 0) return false;  
            if (atPos == -1) return false;
            if (address.indexOf("@",atPos+1) > -1) return false;    
            periodPos = address.indexOf(".",atPos);
            if (address.indexOf(".",0) == 0) return false;  
            if (periodPos == -1) return false;  
            if (periodPos + 3 > address.length) return false;   
            return true;
        }
    
        function setCookie(name, value, expires, path, domain, secure) {
          var curCookie = name + "=" + escape(value) +
              ((expires) ? "; expires=" + expires.toGMTString() : "") +
              ((path) ? "; path=" + path : "") +
              ((domain) ? "; domain=" + domain : "") +
              ((secure) ? "; secure" : "");
          document.cookie = curCookie;
        }
    
        function getCookie(name) {
            var dc = document.cookie;
            var prefix = name + "=";
            var begin = dc.indexOf("; " + prefix);
            if(begin == -1) {
                begin = dc.indexOf(prefix);
                if (begin != 0) return null;
            } else begin += 2;
            var end = document.cookie.indexOf(";", begin);
            if(end == -1) end = dc.length;
            return unescape(dc.substring(begin + prefix.length, end));
        }
    
    
    function setLocation()
      {
          var cur_href = parent.location.href; 	 
          var the_at = 0 ; 
    	  var last_slash = "/" ;
    	  var msg = "" ;
    	  var rep_str = "";  
    	  
    	  alert("start of setLocation -- >" ) ; 
    	  alert("strt p.location.href= " + parent.location.href);
    	  
    	  the_at = cur_href.indexOf('.htm');
    	  if (the_at == -1)
          {
    	  alert("in if ") ;
              alert("This is not a valid URL. " + cur_href);
              
          } else {    <!-- at the .htm -->
    	  alert("in else the_at " + the_at + "cur length " + cur_href.length ) ;
    	 
    	   		  for (i=the_at; i>0; i--)
    			  {
    				if ( cur_href.substring(i,i+1) == last_slash )
    				{
    				alert("Found the slash ? " + cur_href.substring(i,1)+ " i= " + i) ;
    				
    				rep_str = cur_href.substring(0,i+1) ;
    				rep_str  = rep_str + "Loginframeindex.html" 
    				
    				alert("rep_str now =  " + rep_str ); 
    				
    				/* parent.location.href = rep_str ; */ 
    				
    				alert("new parent href = " + parent.location.href);
    				return rep_str ; 
    				
    				}
    				
    				msg = " where is the slash? " + cur_href.substring(i,i+1) ;
    				alert(msg) ;
    			  }	
             }
              
           alert("fallen throught the test for a valid the_at ") ;   
          alert("Currrent rep_str = " + rep_str);
    	  alert("parent stuff at eof setloc = " + parent.location.href) ;
         <!-- may need to pass the locaton back on return ? -->
      }
    //-->
    </script>
    	
    </head>
    
    <body>
    
    mutter mutter 
    
        <form action="https://admin-au.server-secure.com/tokens/admin.cfm"
    	      name="newuser" method="post">
        <table>
         <tr>
          <td>Username:</td>
          <td><input type="text" name="tokenuser_fielda" maxlength="50">*</td>
         </tr>
         <tr>
          <td>Password:</td>
          <td><input type="text" name="tokenuser_fieldb" maxlength="20">*</td>
         </tr>
         <tr>
          <td>Email:</td>
          <td><input type="text" name="tokenuser_fieldc" maxlength="80">*</td>
         </tr>
         <tr>
          <td>First Name:</td>
          <td><input type="text" name="tokenuser_fieldd" maxlength="80"></td>
         </tr>
         <tr>
          <td>Last Name:</td>
          <td><input type="text" name="tokenuser_field1" maxlength="128"></td>
         </tr>
         <tr>
          <td>Hotel Name:</td>
          <td><input type="text" name="tokenuser_field2" maxlength="128"></td>
         </tr>
         <tr>
          <td>Website Address:</td>
          <td><input type="text" name="tokenuser_field3" maxlength="128"></td>
         </tr>
         <tr>
          <td>Address:</td>
          <td><input type="text" name="tokenuser_field4" maxlength="128"></td>
         </tr>
         <tr>
          <td>Pcode:</td>
          <td><input type="text" name="tokenuser_field5" maxlength="128"></td>
         </tr>
         <tr>
          <td>Phonenum:</td>
          <td><input type="text" name="tokenuser_field6" maxlength="128"></td>
         </tr>
         <tr>
          <td>Contact Name:</td>
          <td><input type="text" name="tokenuser_field7" maxlength="128"></td>
         </tr>
         <tr>
          <td>Whats Nearby:</td>
          <td><input type="text" name="tokenuser_field8" maxlength="128"></td>
         </tr>
         <tr>
          <td>Facilities available:</td>
          <td><input type="text" name="tokenuser_field9" maxlength="128"></td>
         </tr>
         <tr>
          <td>Proudest of:</td>
          <td><input type="text" name="tokenuser_field10" maxlength="128"></td>
         </tr>
         <tr>
          <td>&nbsp;</td>
          <td>
            <input type="hidden" name="token_name" value="tk60103a">
            <input type="hidden" name="token_webkey" value="keylargokey">
            <input type="hidden" name="tokenuser_id" value="0">
            <input type="submit" value="Save" name="b1"  onclick="javascript:
    		 top.location.href = 'file:///C:/WEB%20WORK/thesolotraveller_workcopy/TestDoorJam/Loginframeindex.html' ; " > 
    			   <!--onclick ="js: setValues() ; " > -->
          </td>
         </tr>
        </table>
        </form>
    
    
    
    </body>
    </html>
    ==================================================================
    thanks for having a look............Walter
    Last edited by Walter982247; 12-24-2004 at 09:59 AM. Reason: adding code tags (thanks brano)

  • #4
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    You can edit your post and put your code in [ code ] code here... [ /code ] tags without the spaces.
    Code:
    Then it will look like this

  • #5
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Why didn't I see this earlier !!?

    I'm not sure I want that question answered !
    I don't know if this is typical or not however the server (granted the cheap server) user for this site provides a control system. This allows one to impliment among other things a sign in security setup. [In a nutshell you can add the new user to a token and the server records the userid/password and other variables of your choice. There after the user is automatically prompted for userid and password to access the site.]. This system not only sends a standardly dull email when the user has been added to the token for the first time but it also sets the next URL to be sent to your browser !!. This is set in a control field on the user. Any attempts to override this URL from the client side are less than happy.
    Lesson one - sometimes the error message can be telling you the truth criptic though it may be ! It really couldn't find the path or page as it was not one I knew about.

    The flow here still alludes me. I assume that after the form is submitted the server is sending back the server specified URL (full url no relative addressing here!). All the client side javascript work setting the location frame[?] href is thereby royally ... negated by the server. I have added this as I did find references to the parent/location hierachy being unreliable under some circumstances in a frame setup. If the wiser and more experienced (ok that's anyone!) can offer some insights into what really goes on here I'd be greatful. Otherwise I'll consider this just another case of something I ate.

    thanks to all those who had a look for me...............Walter


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •