getElementById

View: New views
2 Messages — Rating Filter:   Alert me  

getElementById

by Boštjan Jerko-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello!

I have an HTML page from which I'd like to read username data and url  
to my javascript, for example:

...
<form name="podatki>
        <input name="uname" id="uname" value="user1" type="hidden"></input>
        <input url="url" id="url" value="http://www.mochikit.com"  
type="hidden"></input>
</form>
<a href="#" onClick="jscript()">link</a>
....

in jscript.js the code is:

function jscript()
{
  uname=document.geElementById("uname");
  url=document.getElementById("url");
  log(uname);
  log(url);
}

I expected to get from log user1 and http://www.mochikit.com, but I got

[object HTMLInputElement]

I guess that is correct but how to get data from HTML page??

Hope I was clear with the question.

Boštjan


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "MochiKit" group.
To post to this group, send email to mochikit@...
To unsubscribe from this group, send email to mochikit+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: getElementById

by troels knak-nielsen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    var url = document.getElementById("url").value;

but if you're using MochiKit, you could shorten it to:

    var url = $("url").value;

--
troels

2009/1/25 Boštjan Jerko <mlist@...>:

>
> Hello!
>
> I have an HTML page from which I'd like to read username data and url
> to my javascript, for example:
>
> ...
> <form name="podatki>
>        <input name="uname" id="uname" value="user1" type="hidden"></input>
>        <input url="url" id="url" value="http://www.mochikit.com"
> type="hidden"></input>
> </form>
> <a href="#" onClick="jscript()">link</a>
> ....
>
> in jscript.js the code is:
>
> function jscript()
> {
>  uname=document.geElementById("uname");
>  url=document.getElementById("url");
>  log(uname);
>  log(url);
> }
>
> I expected to get from log user1 and http://www.mochikit.com, but I got
>
> [object HTMLInputElement]
>
> I guess that is correct but how to get data from HTML page??
>
> Hope I was clear with the question.
>
> Boštjan
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "MochiKit" group.
To post to this group, send email to mochikit@...
To unsubscribe from this group, send email to mochikit+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---