GeeCON Prague 2014*
The moose likes HTML, CSS and JavaScript and the fly likes Id name to javascript 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 "Id name to javascript" Watch "Id name to javascript" New topic
Author

Id name to javascript

Frank Jacobsen
Ranch Hand

Joined: May 17, 2002
Posts: 353
I know the getelementbyid in javascript, but what im trying to do, is to tage the id form the html to the javascript.....
And then set it in the value off an input field.
But this dosent work...
I dont know the name off the id.
If i cant use this, what should i use instead ...







Frank
[ April 20, 2007: Message edited by: Bear Bibeault ]
Roger F. Gay
Ranch Hand

Joined: Feb 16, 2007
Posts: 376
May I ask a question? I guess that the %% parts indicate that you're using ASP? Is that right? Server side processing?

If you're trying to fetch information within the page and put it somewhere else in the page, why would you use server-side processes? Does the information also need to be recorded somewhere on the server?


Correlation does not prove causality.
Frank Jacobsen
Ranch Hand

Joined: May 17, 2002
Posts: 353
No i dont use ASP, the %% is call something to url encoding, soo dont look at this part i get my alerts, so the script is running, i dont get the last alert....

SO what is wrong, i need to get the id, then i want to save the id in the form, i need the field, later when i submit tho form !
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
It would be a lot easier if you showed us the rendered code without the serverside markup.

Eric
Frank Jacobsen
Ranch Hand

Joined: May 17, 2002
Posts: 353
Here is the code, when im running this function all my alerts is shown, but when i submit the form, my input filed focus contains "Null" and not the id value....



Frank
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

document.lonOverforselForm.focus.value = focusOnElement;


You have a form element named focus? Bad idea as that's the name of a JavaScript function.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Frank Jacobsen
Ranch Hand

Joined: May 17, 2002
Posts: 353
Maybe is a bad idea, but this is not the problem, i just renamed it to "hallo", and i still get null in my input field....

Its maybe not possible to get the id value out in a javascript ???

Frank
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

Next bad idea: what are you trying to do with this?



You are assigning an element as the value of the field. Eh?

P.S. I really have no idea what you are trying to accomplish because phrases like "but what im trying to do, is to tage the id form the html to the javascript." do not help. "tage"? "id form the html"?
[ April 20, 2007: Message edited by: Bear Bibeault ]
Roger F. Gay
Ranch Hand

Joined: Feb 16, 2007
Posts: 376
yahaa ... take the id from the html element into javascript ... using onfocus, he wants his javascript to know what is in focus .... obvious I suppose, but I'm just writing it out because it seems like something that could be useful.

I don't think
onfocus='javascript:setfocus(this);'

"this" doesn't provide the element id does it?

Perhaps a little more of the code might help to provide a little more context: the element with an id ...
 
GeeCON Prague 2014
 
subject: Id name to javascript