Solved

Javascript error in firefox

Posted on 2011-09-05
11
624 Views
Last Modified: 2012-06-27
Hi,

I have a jsp page that invokes the dateTimePicker calendar javascript. I have uploaded the javascript file. The line 'exDateTime=document.getElementById(pCtrl).value' is erroring out in the Firefox browser but not in any of the other browsers. Can you please help.
thanks,
Anu Calendar.js
0
Comment
Question by:Anandhi1
  • 6
  • 3
  • 2
11 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 36484790
put the code inside initializing the calendar inside :

window.onload = function() {
     // put INIT ONLY here
}

or use an other plugin :
http://www.ama3.com/anytime/
http://jqueryui.com/demos/datepicker/

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 36484796
Show your line where you call that function NewCal()
0
 
LVL 1

Author Comment

by:Anandhi1
ID: 36485076
Here is my code in the jsp where I am calling the function NewCal()

<netui:image src="/resources/images/cal.GIF"
                                    onClick="javascript:NewCal([getNetuiTagName('dateObserved', this)],'MMddyyyy',false,24);" tagId="calendar" />
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 36485211
As far as I see it should be without squere braces:

<netui:image src="/resources/images/cal.GIF"
                                    onClick="javascript:NewCal(getNetuiTagName('dateObserved', this),'MMddyyyy',false,24);" tagId="calendar" />

You can do a check like this;

<netui:image src="/resources/images/cal.GIF"
                                    onClick="javascript:prompt('id',getNetuiTagName('dateObserved', this));NewCal([getNetuiTagName('dateObserved', this)],'MMddyyyy',false,24);" tagId="calendar" />

Afterwards look into browser page html source for that prompted id.

0
 
LVL 1

Author Comment

by:Anandhi1
ID: 36512832
I found out where the problem was.
The  getElementID() was null in firefox. So when value method was called on that it caused the error.
I had to change it to the following code.
document[getNetuiTagName("formName", scope)][getNetuiTagName("elementId", scope)]

But now I am stuck at this point. When the user clicks on the calendar icon, the calendar displays but it does not select the value.

The code where it is errorring is here.
<a href=\"javascript:winMain.document.getElementById('"+Cal.Ctrl+"').value='"

The message in the error console says that winMain.document.getElementById("portlet_1_2{actionform.date}") is null.  

Can someone please help?

thanks,
Anu

0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 82

Expert Comment

by:leakim971
ID: 36512988
yes if you provide a link to see the page
0
 
LVL 1

Author Comment

by:Anandhi1
ID: 36513040
When the user clicks on a date on the calendar, the date is populated in the field in the jsp page.
This works fine in the IE browser. But in the Firefox it gives the error that winMain.document.getElementById("portlet_1_2{actionform.date}") is null.  

I believe the value 'portlet_1_2{actionform.date}' is the field from the jsp.

I am using netui tags in the jsp.
When I am using the regular html tags, this works perfectly fine.

I am not sure which page you would like to see. I have already uploaded the javascript file.
I am pasting below the part of the code in the jsp where we invoke the javascript function.

<tr>
                                <td width="250"> Date situation was observed ** </td>
                                <td colspan="3">
                                <netui:textBox dataSource="actionForm.date" tagId="dateObserved"/>
                                <netui:image src="/resources/images/cal.GIF"
                                                      onClick="javascript:NewCal(getNetuiTagName('dateObserved', this),'MMddyyyy',false,24);" tagId="calendar" />
                                         
                                </td>
                            </tr>



0
 
LVL 82

Expert Comment

by:leakim971
ID: 36513087
check this page : http://www.w3schools.com/tags/att_standard_id.asp

Naming rules:

Must begin with a letter A-Z or a-z
Can be followed by: letters (A-Za-z), digits (0-9), hyphens ("-"), underscores ("_"), colons (":"), and periods (".")
Values are case-sensitive


portlet_1_2{actionform.date}

just a thought...
0
 
LVL 1

Author Comment

by:Anandhi1
ID: 36513118
Thanks for pointing out.

It may not recognize the curly braces  { }. But the value 'portlet_1_2{actionform.date} is generated by the weblogic portal.  
0
 
LVL 1

Accepted Solution

by:
Anandhi1 earned 0 total points
ID: 36544252
The solution is found for this problem.
<a href=\"javascript:winMain.document.getElementById('"+Cal.Ctrl+"').value
is rewritten as
<a href=\"javascript:winMain.document.getElementById('"+"dateObserved"+"').value

where var dateObserved = document[getNetuiTagName("formName", scope)][getNetuiTagName("elementId", scope)]


Now this works in both IE and Firefox

thanks
0
 
LVL 1

Author Closing Comment

by:Anandhi1
ID: 36565458
I found this solution from other sources
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Form submit issue 11 56
Change properties of a dialog box 1 22
Accessing property value in an object. 1 18
Video won't play 5 21
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now