object expected in ie but not in ff or safari

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • danovics
    New Member
    • Jul 2008
    • 5

    object expected in ie but not in ff or safari

    I made a website for my friend
    There is a date table from which the user can select a date and time.
    When he or she clicks the date, an internal javascript call is starting.
    This script hides the datum table div and shows a contact form div, which is hidden when the page is loaded. The js fills out the choosen date in the contact form.

    It works fine in ff and in safari, but in ie not.
    Ie shows an error: "object expected".

    The clickable dates are in <a></a> tags, I tried to change them to <div>-s with css class that has :hover attributes too. But it didn't help.

    The onclick still doesn't work.

    If anybody could help, I would be very glad, because I just don't have any idea.

    Oh, and dorry about my very poor English.


    http://www.lakberendez otanfolyam.hu/_4_idopontok.ht ml
  • rohypnol
    New Member
    • Dec 2007
    • 54

    #2
    Please paste the JavaScript code, otherwise we have no clue what you're talking about.

    Comment

    • danovics
      New Member
      • Jul 2008
      • 5

      #3
      Originally posted by rohypnol
      Please paste the JavaScript code, otherwise we have no clue what you're talking about.
      I just didn't want to waste here the pleace, because i thought that the internal js code could be seen by visiting the link and choosing 'view source'. But as i arrive home, i'll post the whole script. Thanks a lot!

      Comment

      • rohypnol
        New Member
        • Dec 2007
        • 54

        #4
        Originally posted by danovics
        I just didn't want to waste here the pleace
        Don't worry about that. You can use as much space as needed to post your code because later someone will google for something and they'll find this post which might answer their question if they'd see the javascript code but by that time you'll probably change or completely remove the page and this post will become useless to others.

        Comment

        • danovics
          New Member
          • Jul 2008
          • 5

          #5
          Okey
          Here is the external javascript code followed by the detail of html code, which use the onclick.
          Thanks for helping


          Code:
          	<script type="text/javascript">
          	<!-- Begin
          	
          	function checkform(werq) {
          		var pass=true
          		var nev = document.getElementById("nevmezo").value;
            		var ujra_nev = document.getElementById('hibas_nev')
          		if (nev.length<4) 
          			{
          			ujra_nev.innerHTML = "Kérem adja meg a nevét";
          			document.getElementById("nevmezo").focus()
          			return false
          			}
          			
          			return ValidateEmail()
          			}
          	
          	
          	function echeck(str) {
            		var ujra_email = document.getElementById('hibas_email')  		
            		var at="@"
            		var dot="."
            		var lat=str.indexOf(at)
            		var lstr=str.length
            		var ldot=str.indexOf(dot)
            		if (str.indexOf(at)==-1){
               		ujra_email.innerHTML = "Érvénytelen Email cím"
               		return false
            		}
            		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
               		ujra_email.innerHTML = "Érvénytelen Email cím"
               		return false
            		}
          	  	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
               		ujra_email.innerHTML = "Érvénytelen Email cím"
                		return false
            		}
             		if (str.indexOf(at,(lat+1))!=-1){
               		ujra_email.innerHTML = "Érvénytelen Email cím"
                		return false
             		}
             		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
               		ujra_email.innerHTML = "Érvénytelen Email cím"
                		return false
             		}
             		if (str.indexOf(dot,(lat+2))==-1){
               		ujra_email.innerHTML = "Érvénytelen Email cím"
                		return false
             		}
             		if (str.indexOf(" ")!=-1){
               		ujra_email.innerHTML = "Érvénytelen Email cím"
                		return false
             		}
             		return true          
          	}
          
          	function ValidateEmail(){
            		var emailID=document.jelentkezes.email
            		var ujra_email = document.getElementById('hibas_email')
            
            		if ((emailID.value==null)||(emailID.value=="")){
               		ujra_email.innerHTML = "Kérem adja meg az email címét"
              		emailID.focus()
              		return false
            		}
            		
          		if (echeck(emailID.value)==false){
                  	emailID.focus()
              		return false
              	}
            		return true
           	}
          	
          	function rossz_email_clear(){
          		document.getElementById('hibas_email').innerHTML=""
          	}
          		function rossz_nev_clear(){
          		document.getElementById('hibas_nev').innerHTML=""
          	}
          
          	function show_jelentkezes(ezt){
          			
          		var figytext;					// figyelmeztető szöveg
          		var napok = new Array(); 		// kiválasztott nap meghatározása 
          			napok[1] = "hétfő";
          			napok[2] = "kedd";
          			napok[3] = "szerda";
          			napok[4] = "csütörtök";
          			napok[5] = "péntek";
          			napok[6] = "hétvége";
          		var nap = napok[ezt.parentNode.parentNode.rowIndex];				
          		var ido=ezt.innerHTML;			// Választott időpont		
          		var helyszinek = new Array();	// Választott helyszín meghatározása
          			helyszinek[1] = "Marcibányi Téri Művelődési Központ";
          			helyszinek[2] = "Deák Téri Gimnázium";
          		var helyszin = helyszinek[ezt.parentNode.cellIndex];		
          						
          /*
          		switch (nap) 	// Hétköznapi vagy hétvégi
          			{
          				case "hétvége":
          					tipushu = "Hétvégi";
          					figytext = ("Ön egy hétvégi kurusunkat választotta, melyet a " +  helyszin + "ban " + ido + " tartunk.");
          					
          					
          					
          					break;
          				default:
          					tipushu = "Hétköznapi";
          					figytext = ("Ön egy hétköznapi kurusunkat választotta, melyet a " + helyszin + "ban " + nap + "i napokon " + ido + " óráig tartunk.");
          					break;
          			}		
          */
          
          		document.getElementById('valasztotthely').innerHTML=helyszin;
          		document.getElementById('valasztottnap').innerHTML = nap;
          		document.getElementById('valasztottido').innerHTML = ido;
          
          		
          		// láthatatlan form elemek feltöltése értékkel - ezek mennek el a submit után emailen
          		document.getElementsByName('Helyszín')[0].value = helyszin;			// helyszíne
          		document.getElementsByName('Nap')[0].value = nap;					// nap
          		document.getElementsByName('Időpont')[0].value = ido;				// időpont
          
          		// eltűnteti a táblázatot és megjeleníti a jelentkezési űrlapot
          		document.getElementById('hide').style.display = "none";
          		document.getElementById('show').style.display = "block";
          	}
          	-->	//  End --
          	</script>

          [HTML]<div class="newtbl">
          <table> <!-- új táblázat -->
          <tr class="first_ro w">
          <td class="cell_day "></td>
          <td class="cell_mar ci_time"><a href="#marci">M arczibányi Téri Művelődési Központ</a></td>
          <td class="cell_dea k_time"><a href="#deak">De ák Téri Gimnázium</a></td>
          <td>Kurzus első napja</td>
          </tr>
          <tr class="row_days ">
          <td class="cell_day ">Hétfő</td>
          <td class="cell_mar ci_time"> <!-- Hétfő Marczibányi -->
          "A" &nbsp;&nbsp; <a href="#" name="idolink" onclick="show_j elentkezes(this );">18.00-19.30</a>
          </td>
          <td class="cell_dea k_time"> <!-- Hétfő Deák -->
          <a href="#" name="idolink" onclick="show_j elentkezes(this );"></a>-
          </td>
          <td class="cell_fir st"> <!-- Első hétfő-->
          Szept. 22.
          </td>
          </tr>
          <tr class="row_days ">
          <td class="cell_day ">Kedd</td>
          <td class="cell_mar ci_time"> <!-- Kedd Marczibányi -->
          <a href="#" name="idolink" onclick="show_j elentkezes(this );"></a>-
          </td>
          <td class="cell_dea k_time"> <!-- Kedd Deák -->
          "B" &nbsp;&nbsp; <a href="#" name="idolink" onclick="show_j elentkezes(this );">16.00-17.30</a><br />
          "C" &nbsp;&nbsp; <a href="#" name="idolink" onclick="show_j elentkezes(this );">17.00-18.30</a>
          </td>
          <td class="cell_fir st"> <!-- Első kedd-->
          Szept. 16.
          </td>
          </td>
          </tr>
          <tr class="row_days ">
          <td class="cell_day ">Szerda</td>
          <td class="cell_mar ci_time"> <!-- Szerda Marczibányi -->
          "D" &nbsp;&nbsp; <a href="#" name="idolink" onclick="show_j elentkezes(this );">10.30-12.00</a><br />
          "E" &nbsp;&nbsp; <a href="#" name="idolink" onclick="show_j elentkezes(this );">18.00-19.30</a>
          </td>
          <td class="cell_dea k_time"> <!-- Szerda Deák -->
          <a href="#" name="idolink" onclick="show_j elentkezes(this );"></a>-
          </td>
          <td class="cell_fir st"> <!-- Első szerda-->
          Szept. 24.
          </td>
          </td>
          </tr>
          <tr class="row_days ">
          <td class="cell_day ">Csütörtök </td>
          <td class="cell_mar ci_time"> <!-- Csütörtök Marczibányi -->
          <a href="#" name="idolink" onclick="show_j elentkezes(this );"></a>-
          </td>
          <td class="cell_dea k_time"> <!-- Csütörtök Deák -->
          "F" &nbsp;&nbsp; <a href="#" name="idolink" onclick="show_j elentkezes(this );">16.00-17.30</a><br />
          "G" &nbsp;&nbsp; <a href="#" name="idolink" onclick="show_j elentkezes(this );">17.00-18.30</a>
          </td>
          </td>
          <td class="cell_fir st"> <!-- Első csütörtök-->
          Szept. 18.
          </td>
          </tr>
          <tr class="row_days ">
          <td class="cell_day ">Péntek</td>
          <td class="cell_mar ci_time"> <!-- Péntek Marczibányi -->
          <a href="#" name="idolink" onclick="show_j elentkezes(this );"></a>-
          </td>
          <td class="cell_dea k_time"> <!-- Péntek Deák -->
          <a href="#" name="idolink" onclick="show_j elentkezes(this );"></a>-
          </td>
          <td class="cell_fir st"> <!-- Első péntek-->
          <a href="#" name="idolink" onclick="show_j elentkezes(this );"></a>-
          </td>
          </td>
          </tr>
          <tr>
          <td class="cell_day ">Hétvége</td>
          <td class="cell_mar ci_time"> <!-- Hétvége Marczibányi -->
          <a href="#" name="idolink" onclick="show_j elentkezes(this );">Szeptembe r 27-28.</a> <br />
          <a href="#" name="idolink" onclick="show_j elentkezes(this );">Október 11-12.</a> <br />
          <a href="#" name="idolink" onclick="show_j elentkezes(this );">Október 18-19.</a> <br />
          <a href="#" name="idolink" onclick="show_j elentkezes(this );">November 8-9.</a> <br />
          <a href="#" name="idolink" onclick="show_j elentkezes(this );">November 15-16.</a> <br />
          </td>
          <td class="cell_dea k_time"> <!-- Hétvége Deák -->
          <a href="#" name="idolink" onclick="show_j elentkezes(this );">Szeptembe r 20-21.</a><br />
          <a href="#" name="idolink" onclick="show_j elentkezes(this );">November 22-23.</a><br />(függőben)</td>
          </td>
          </tr>
          </table> <!-- új táblázat vége -->
          </div>[/HTML]
          Last edited by acoder; Jul 29 '08, 04:10 PM. Reason: Added [code] tags

          Comment

          • rohypnol
            New Member
            • Dec 2007
            • 54

            #6
            Next time please use [ code ] tags when posting.

            If you copy the whole code in your post into a text editor you should go to line 115 and fix that syntax error. Then, you should create the valasztotthely, valasztottnap and valasztottido HTML elements because they don't exist! I've tried to put your script+html into a file and open it using Firefox and i got too many errors. You should try to install Firebug and open the page in Firefox and check the Firebug console. You will see lots of errors which you should fix before asking for help because not many people would want to look over code with variable names and comments written in a foreign language AND with syntax/compilation errors.

            Also, the email validation function seems a bit too complicated, you could validate emails using regular expressions like so:
            Code:
              function isValidEmail(email_address)
            {
              var regex = /^[a-zA-Z0-9.+_-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]+$/;
              return regex.test(email_address);
            }
            Regards,
            Tom

            Comment

            • danovics
              New Member
              • Jul 2008
              • 5

              #7
              Thank for advices. I'm really newby... I'll try to do my best.
              So I made a very very short code, which I inserted below.
              The problem is the same.

              Code:
              <html>
              <head>
              	<script type="text/javascript">
              	<!-- Begin	
              		function show_jelentkezes(ezt){
              		alert ("This alert messeage will show up in Firefox and in Safari, but NOT in Internet Explorer. Why?")
              		}	
              	-->
              	</script> 
              </head>
              <body>
              	<div id="idolink" onclick="show_jelentkezes(this);">click</div>
              </body>

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                It does show up in IE. Which version are you using?

                Comment

                • danovics
                  New Member
                  • Jul 2008
                  • 5

                  #9
                  I'm soo soo stupid!!!!!

                  I had the end lines of script:

                  Code:
                  	-->	//  End --
                  	</script>
                  So I mixed up two kind of comment tags. Safari and FF "ate" it, but ie didn't.

                  Very big sorry again, for wasting your time!!!
                  And thank You a lot for trying to help me.... (But as we know, nobody can help a stupid man.:)

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #10
                    Hey, that doesn't make you stupid. OK, it shouldn't have been there, but there's plenty of times when the most obvious of mistakes isn't so obvious.

                    Glad to hear that it's working and you managed to figure it out yourself. I would say that you should post the code which causes the error, not something similar.

                    Comment

                    Working...