• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Id name to javascript

 
Frank Jacobsen
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 408
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Frank Jacobsen
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be a lot easier if you showed us the rendered code without the serverside markup.

Eric
 
Frank Jacobsen
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
document.lonOverforselForm.focus.value = focusOnElement;


You have a form element named focus? Bad idea as that's the name of a JavaScript function.
 
Frank Jacobsen
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 408
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic