HighDots Forums  

Re: GetElementbyID Issue

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: GetElementbyID Issue in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Thomas 'PointedEars' Lahn
 
Posts: n/a

Default Re: GetElementbyID Issue - 06-22-2008 , 12:29 PM






sid (AT) sidroberts (DOT) co.uk wrote:
Quote:
On Jun 18, 8:08 pm, Chico Che <jsis... (AT) yahoo (DOT) com> wrote:
1. A user logs in to web app thru ie
2. They do an invoice for a particular item
3. Record the transaction and two text boxes get filled out on browser app

Is it possible to create maybe a ie toolbar button that would grab data
from those two text boxes(id is known already from ie developer bar).

Hopefully this explains a little better

script type="text/javascript"
function grabInputContents(id) {
var input = document.getElementById(id);
return input.value;
}
/script

It's important to note the lowercase "d" in Id. getElementById returns
the DOM object of an element using the ID specified.
It is also important to know that document.getElementById() may return a
value that is not convertible to an object reference in which case the
`return' statement as it is will cause a runtime error.

A possible fix:

function grabInputContents(id)
{
var input = document.getElementById(id);
return input ? input.value : "";
}

BTW, your indentation and quoting sucks.

http://jibbering.com/faq/


PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.