• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JS function called from JSP works fine in FireFox won't work in IE

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I was wondering if anybody could suggest anything please.

I have a JavaScript function :
function checkNullability(fieldName, actualFieldName){
var ruleName= fieldName+"Nullable";
var ruleNameNullable = evXl(ruleName);
var value = actualFieldName.value;
if (ruleNameNullable=="false" && (value==null || value==""))
{
alert("This is a mandatory field. Please enter something");
actualFieldName.focus();
}
}

and it's being called from JSP. this function works fine in Firefox but won't work in IE. Apologies for having to change write evXl here. I can't write evXl with an "a" replacing the X due to security controls.

I've been told that by a colleague that the problem might be because the name being passed to the checkNullability form is like:
name="staticDataItemList[3].value"
in the outputted HTML code.

The value of the actualFieldName is set in the JSP as:
lt html:text name="staticDataItemList" property="value" size="50" indexed="true"
onclXck= "setActualFieldName('name')"
/gt

Sorry for the unreadable code. I can't post this topic with the word onclXck (where i= X ) in it due to security controls on the JavaRanch website.

Can anybody suggest anything please ?

Thanks in advance,
Trish.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

and it's being called from JSP.


I really hate to see that usage - its a sign of confusion. JSP is writing an HTML page that contains (you trust) some JavaScript. JSP is NOT calling anything, it is writing plain text that the browser is supposed to interpret.

Now, with that distinction clearly in mind, do a view source in the browser and see what has actually been written. Your JS will probably have to be modified to let it cope with both IE and Firefox.

Bill
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Trish, your code will be more readable if you use the UBB code tags to preserve its formatting. You can include the word onclick by substituting the HTML entity o for the 'o' in onclick.

And, as William pointed out, the fact that an HTML/Javascript page was generated by a JSP is moot, so I've moved this off to the HTML forum for you.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mozilla and Firefox have a JavaScript console on it. Look at it, it gives you an error message that should tell you what your issue is.

Eric
 
Trish Hartnett
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

thank you for replying. The JavaScript console in FireFox shows no errors. Same with the one in IE. It's almost as if IE can't has problems recognising fieldnames that have full stops in them.

Thanks in advance for any suggestions at all,
Trish.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whoops, I switch browsers when I posted that. I thought you said it dod not work in Firefox...

It is a lot better to change this:

to something like this:


Eric
 
Trish Hartnett
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for replying, but I don't think that the problem is with the eval.
I tried writing a small function to store the fieldName as it appears in the form:

function setFormFieldName(actualFieldNameInForm){
actualFieldName = actualFieldNameInForm;
alert("field name as it appears in HTML: " +actualFieldName );
}

The alert works in FireFox but not in IE. The fieldName is staticDataItemList[3].value
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.webdeveloper.com/forum/showthread.php?p=545458#post545458

Eric
 
Trish Hartnett
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sorry. I know shouldn't hedge bets by posting on more than one website at one time.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I post on 12 different places daily, I really do not care. Just do not feel like talking in 2.

Eric
 
Trish Hartnett
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh thank you so so much. I really just want to get this nasty bit of stuff out the way :>
reply
    Bookmark Topic Watch Topic
  • New Topic