aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Cannot retrieve hidden values, declared in form tag, in Firefox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Cannot retrieve hidden values, declared in form tag, in Firefox" Watch "Cannot retrieve hidden values, declared in form tag, in Firefox" New topic
Author

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

Mattias Andersson
Greenhorn

Joined: Nov 17, 2010
Posts: 20
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!


It's better to be approximately right than exactly wrong.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

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.)


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mattias Andersson
Greenhorn

Joined: Nov 17, 2010
Posts: 20
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

Joined: Jan 10, 2002
Posts: 61206
    
  66

Just saying "it didn't work" isn't helpful. Post the code that didn't work.
Mattias Andersson
Greenhorn

Joined: Nov 17, 2010
Posts: 20
I have tried the following and am feeling like a complete nitwit.



Regards
/Mattias
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

What's with all the 'apn' stuff?
Mattias Andersson
Greenhorn

Joined: Nov 17, 2010
Posts: 20
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

Joined: Jan 10, 2002
Posts: 61206
    
  66

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

Joined: Nov 17, 2010
Posts: 20
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

Joined: Jan 10, 2002
Posts: 61206
    
  66

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

Joined: Nov 17, 2010
Posts: 20
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

Joined: Jan 10, 2002
Posts: 61206
    
  66

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

Joined: Nov 17, 2010
Posts: 20
Sorry for the hasted editing of my post.
My bad.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

You can assign an id to any element.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot retrieve hidden values, declared in form tag, in Firefox