Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot retrieve hidden values, declared in form tag, in Firefox

 
Mattias Andersson
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

This is my first post and first forum membership of this nature.
There where a lot of forums to choose from, but this site feels really solid and serious, thanks

About my question:
I have a javascript retrieving hidden values decalred in a form, like this:

The javascript snippet:


The JSP snippet:


You see, the javascript code works just fine with Internet Explorer, but not with Firefox.
The "/addDevice" is Struts specific and I don't think that has anything to do with the problem at hand.
Can anyone see what the problem is?
Thanks!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

You should be using document.getElementById() to get the elements.

(In the future, in this forum please post final HTML rather than Struts markup.)
 
Mattias Andersson
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for your reply Bear!
I really appreciate it.
But I've tried your suggestion in many different ways and I can't seem to get my hidden properties.

Maybe I failed to explain my problem
It is the hidden properties I would like to set from the javascript code.

Maybe you could give me a "hands on" code example?


Thank you very much.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just saying "it didn't work" isn't helpful. Post the code that didn't work.
 
Mattias Andersson
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried the following and am feeling like a complete nitwit.



Regards
/Mattias
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's with all the 'apn' stuff?
 
Mattias Andersson
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is a bean attribute which I want to set from the javascript code.

The code example I first posted actually works with Internet Explorer.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you are saying that when apn* is the id value (not the name value -- that's completely different) of a form element, that:



doesn't set the value?

I'm not buying it. Something else is factoring in.





* "apn"? Reallly? What's wrong with using real words?
 
Mattias Andersson
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
APN - Access Point Name, a setting for the General Packet Radio Service (GPRS)

As I am implying in my third post. I can't get the syntax correct.

The above code snippet doesn't set the value, of the attribute apn.
The only thing I have found working is:

Which only works in Internet Explorer, but not in Firefox.

apn is declared as a hidden property referring to an attribute of a bean.
The only id I have declared is "addDeviceForm".
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mattias Andersson wrote:The only id I have declared is "addDeviceForm".

Well then, of course nothing is going to work.

Assign an id to any element you want to address. You can't reference something by id if it doesn't have one!
 
Mattias Andersson
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you are saying that I can declare an id-tag to the hidden property?
Well, thats great then.
Can't test it right now though
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mattias Andersson wrote:So you are saying that I can declare apn both as a hidden property and as an indexed property at the same time?
It is essential that the hidden property is set from the javascript.

I have no idea what you are trying to say here. "hidden property" and "indexed property" are not HTML or JavaScript concepts.

It's as simple as the following:
Just add an id to the element and you will be able to address it. Nothing else comes into play. You're making this way more complicated than it needs to be!
 
Mattias Andersson
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the hasted editing of my post.
My bad.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can assign an id to any element.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic