By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,568 Members | 1,196 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,568 IT Pros & Developers. It's quick & easy.

object expected in ie but not in ff or safari

P: 5
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.lakberendezotanfolyam.hu/_4_idopontok.html
Jul 28 '08 #1
Share this Question
Share on Google+
9 Replies


rohypnol
P: 54
Please paste the JavaScript code, otherwise we have no clue what you're talking about.
Jul 28 '08 #2

P: 5
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!
Jul 28 '08 #3

rohypnol
P: 54
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.
Jul 29 '08 #4

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


Expand|Select|Wrap|Line Numbers
  1.     <script type="text/javascript">
  2.     <!-- Begin
  3.  
  4.     function checkform(werq) {
  5.         var pass=true
  6.         var nev = document.getElementById("nevmezo").value;
  7.           var ujra_nev = document.getElementById('hibas_nev')
  8.         if (nev.length<4) 
  9.             {
  10.             ujra_nev.innerHTML = "Kérem adja meg a nevét";
  11.             document.getElementById("nevmezo").focus()
  12.             return false
  13.             }
  14.  
  15.             return ValidateEmail()
  16.             }
  17.  
  18.  
  19.     function echeck(str) {
  20.           var ujra_email = document.getElementById('hibas_email')          
  21.           var at="@"
  22.           var dot="."
  23.           var lat=str.indexOf(at)
  24.           var lstr=str.length
  25.           var ldot=str.indexOf(dot)
  26.           if (str.indexOf(at)==-1){
  27.              ujra_email.innerHTML = "Érvénytelen Email cím"
  28.              return false
  29.           }
  30.           if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
  31.              ujra_email.innerHTML = "Érvénytelen Email cím"
  32.              return false
  33.           }
  34.           if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
  35.              ujra_email.innerHTML = "Érvénytelen Email cím"
  36.               return false
  37.           }
  38.            if (str.indexOf(at,(lat+1))!=-1){
  39.              ujra_email.innerHTML = "Érvénytelen Email cím"
  40.               return false
  41.            }
  42.            if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
  43.              ujra_email.innerHTML = "Érvénytelen Email cím"
  44.               return false
  45.            }
  46.            if (str.indexOf(dot,(lat+2))==-1){
  47.              ujra_email.innerHTML = "Érvénytelen Email cím"
  48.               return false
  49.            }
  50.            if (str.indexOf(" ")!=-1){
  51.              ujra_email.innerHTML = "Érvénytelen Email cím"
  52.               return false
  53.            }
  54.            return true          
  55.     }
  56.  
  57.     function ValidateEmail(){
  58.           var emailID=document.jelentkezes.email
  59.           var ujra_email = document.getElementById('hibas_email')
  60.  
  61.           if ((emailID.value==null)||(emailID.value=="")){
  62.              ujra_email.innerHTML = "Kérem adja meg az email címét"
  63.             emailID.focus()
  64.             return false
  65.           }
  66.  
  67.         if (echeck(emailID.value)==false){
  68.             emailID.focus()
  69.             return false
  70.         }
  71.           return true
  72.      }
  73.  
  74.     function rossz_email_clear(){
  75.         document.getElementById('hibas_email').innerHTML=""
  76.     }
  77.         function rossz_nev_clear(){
  78.         document.getElementById('hibas_nev').innerHTML=""
  79.     }
  80.  
  81.     function show_jelentkezes(ezt){
  82.  
  83.         var figytext;                    // figyelmeztető szöveg
  84.         var napok = new Array();         // kiválasztott nap meghatározása 
  85.             napok[1] = "hétfő";
  86.             napok[2] = "kedd";
  87.             napok[3] = "szerda";
  88.             napok[4] = "csütörtök";
  89.             napok[5] = "péntek";
  90.             napok[6] = "hétvége";
  91.         var nap = napok[ezt.parentNode.parentNode.rowIndex];                
  92.         var ido=ezt.innerHTML;            // Választott időpont        
  93.         var helyszinek = new Array();    // Választott helyszín meghatározása
  94.             helyszinek[1] = "Marcibányi Téri Művelődési Központ";
  95.             helyszinek[2] = "Deák Téri Gimnázium";
  96.         var helyszin = helyszinek[ezt.parentNode.cellIndex];        
  97.  
  98. /*
  99.         switch (nap)     // Hétköznapi vagy hétvégi
  100.             {
  101.                 case "hétvége":
  102.                     tipushu = "Hétvégi";
  103.                     figytext = ("Ön egy hétvégi kurusunkat választotta, melyet a " +  helyszin + "ban " + ido + " tartunk.");
  104.  
  105.  
  106.  
  107.                     break;
  108.                 default:
  109.                     tipushu = "Hétköznapi";
  110.                     figytext = ("Ön egy hétköznapi kurusunkat választotta, melyet a " + helyszin + "ban " + nap + "i napokon " + ido + " óráig tartunk.");
  111.                     break;
  112.             }        
  113. */
  114.  
  115.         document.getElementById('valasztotthely').innerHTML=helyszin;
  116.         document.getElementById('valasztottnap').innerHTML = nap;
  117.         document.getElementById('valasztottido').innerHTML = ido;
  118.  
  119.  
  120.         // láthatatlan form elemek feltöltése értékkel - ezek mennek el a submit után emailen
  121.         document.getElementsByName('Helyszín')[0].value = helyszin;            // helyszíne
  122.         document.getElementsByName('Nap')[0].value = nap;                    // nap
  123.         document.getElementsByName('Időpont')[0].value = ido;                // időpont
  124.  
  125.         // eltűnteti a táblázatot és megjeleníti a jelentkezési űrlapot
  126.         document.getElementById('hide').style.display = "none";
  127.         document.getElementById('show').style.display = "block";
  128.     }
  129.     -->    //  End --
  130.     </script> 
  131.  

[HTML]<div class="newtbl">
<table> <!-- új táblázat -->
<tr class="first_row">
<td class="cell_day"></td>
<td class="cell_marci_time"><a href="#marci">Marczibányi Téri Művelődési Központ</a></td>
<td class="cell_deak_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_marci_time"> <!-- Hétfő Marczibányi -->
"A" &nbsp;&nbsp; <a href="#" name="idolink" onclick="show_jelentkezes(this);">18.00-19.30</a>
</td>
<td class="cell_deak_time"> <!-- Hétfő Deák -->
<a href="#" name="idolink" onclick="show_jelentkezes(this);"></a>-
</td>
<td class="cell_first"> <!-- Első hétfő-->
Szept. 22.
</td>
</tr>
<tr class="row_days">
<td class="cell_day">Kedd</td>
<td class="cell_marci_time"> <!-- Kedd Marczibányi -->
<a href="#" name="idolink" onclick="show_jelentkezes(this);"></a>-
</td>
<td class="cell_deak_time"> <!-- Kedd Deák -->
"B" &nbsp;&nbsp; <a href="#" name="idolink" onclick="show_jelentkezes(this);">16.00-17.30</a><br />
"C" &nbsp;&nbsp; <a href="#" name="idolink" onclick="show_jelentkezes(this);">17.00-18.30</a>
</td>
<td class="cell_first"> <!-- Első kedd-->
Szept. 16.
</td>
</td>
</tr>
<tr class="row_days">
<td class="cell_day">Szerda</td>
<td class="cell_marci_time"> <!-- Szerda Marczibányi -->
"D" &nbsp;&nbsp; <a href="#" name="idolink" onclick="show_jelentkezes(this);">10.30-12.00</a><br />
"E" &nbsp;&nbsp; <a href="#" name="idolink" onclick="show_jelentkezes(this);">18.00-19.30</a>
</td>
<td class="cell_deak_time"> <!-- Szerda Deák -->
<a href="#" name="idolink" onclick="show_jelentkezes(this);"></a>-
</td>
<td class="cell_first"> <!-- Első szerda-->
Szept. 24.
</td>
</td>
</tr>
<tr class="row_days">
<td class="cell_day">Csütörtök</td>
<td class="cell_marci_time"> <!-- Csütörtök Marczibányi -->
<a href="#" name="idolink" onclick="show_jelentkezes(this);"></a>-
</td>
<td class="cell_deak_time"> <!-- Csütörtök Deák -->
"F" &nbsp;&nbsp; <a href="#" name="idolink" onclick="show_jelentkezes(this);">16.00-17.30</a><br />
"G" &nbsp;&nbsp; <a href="#" name="idolink" onclick="show_jelentkezes(this);">17.00-18.30</a>
</td>
</td>
<td class="cell_first"> <!-- Első csütörtök-->
Szept. 18.
</td>
</tr>
<tr class="row_days">
<td class="cell_day">Péntek</td>
<td class="cell_marci_time"> <!-- Péntek Marczibányi -->
<a href="#" name="idolink" onclick="show_jelentkezes(this);"></a>-
</td>
<td class="cell_deak_time"> <!-- Péntek Deák -->
<a href="#" name="idolink" onclick="show_jelentkezes(this);"></a>-
</td>
<td class="cell_first"> <!-- Első péntek-->
<a href="#" name="idolink" onclick="show_jelentkezes(this);"></a>-
</td>
</td>
</tr>
<tr>
<td class="cell_day">Hétvége</td>
<td class="cell_marci_time"> <!-- Hétvége Marczibányi -->
<a href="#" name="idolink" onclick="show_jelentkezes(this);">Szeptember 27-28.</a> <br />
<a href="#" name="idolink" onclick="show_jelentkezes(this);">Október 11-12.</a> <br />
<a href="#" name="idolink" onclick="show_jelentkezes(this);">Október 18-19.</a> <br />
<a href="#" name="idolink" onclick="show_jelentkezes(this);">November 8-9.</a> <br />
<a href="#" name="idolink" onclick="show_jelentkezes(this);">November 15-16.</a> <br />
</td>
<td class="cell_deak_time"> <!-- Hétvége Deák -->
<a href="#" name="idolink" onclick="show_jelentkezes(this);">Szeptember 20-21.</a><br />
<a href="#" name="idolink" onclick="show_jelentkezes(this);">November 22-23.</a><br />(függőben)</td>
</td>
</tr>
</table> <!-- új táblázat vége -->
</div>[/HTML]
Jul 29 '08 #5

rohypnol
P: 54
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:
Expand|Select|Wrap|Line Numbers
  1.   function isValidEmail(email_address)
  2. {
  3.   var regex = /^[a-zA-Z0-9.+_-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]+$/;
  4.   return regex.test(email_address);
  5. }
Regards,
Tom
Jul 29 '08 #6

P: 5
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.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.     <script type="text/javascript">
  4.     <!-- Begin    
  5.         function show_jelentkezes(ezt){
  6.         alert ("This alert messeage will show up in Firefox and in Safari, but NOT in Internet Explorer. Why?")
  7.         }    
  8.     -->
  9.     </script> 
  10. </head>
  11. <body>
  12.     <div id="idolink" onclick="show_jelentkezes(this);">click</div>
  13. </body>
  14.  
Jul 29 '08 #7

acoder
Expert Mod 15k+
P: 16,027
It does show up in IE. Which version are you using?
Jul 29 '08 #8

P: 5
I'm soo soo stupid!!!!!

I had the end lines of script:

Expand|Select|Wrap|Line Numbers
  1.     -->    //  End --
  2.     </script> 
  3.  
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.:)
Jul 29 '08 #9

acoder
Expert Mod 15k+
P: 16,027
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.
Jul 30 '08 #10

Post your reply

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