Javascript Get a specified element using getElementById()

Javascript Get a specified element using getElementById()

Great, it produces the value for whatever "id" is passed to the function.

http://www.java2s.com/Code/JavaScript/Development/GetaspecifiedelementusinggetElementById.htm
[code:1:1287ede953]
<html>

<head>
<script type="text/javascript">
function getElement(){

var x=document.getElementById("myHeader")
alert("I am a " + x.tagName + " element")

}
</script>
</head>

<body>
<h1 id="myHeader" onclick="getElement()">Click to see what element I am!</h1>
</body>

</html>[/code:1:1287ede953]


I want to get the value of this:

[code:1:98e83dc60d]<input type=hidden id="pid1" value="79.99">[/code:1:98e83dc60d]

The above style doesn't seem to work


Idiot it works, you just need to tell it you want the value!

VPSPackage = document.getElementById('pid'+VPSPackage).[b:3716f02bb7]value[/b:3716f02bb7]


Latest Articles

  • Linux Screen How To Scroll Up and Down
  • Directadmin Install Segfault Error
  • Could not display "trash:///". Error: DBus error org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout
  • SSH error slow login debug1: An invalid name was supplied Cannot determine realm for numeric host address - Solution
  • How To Install CPanel
  • LOG: MAIN PANIC failed to expand condition "${if eq {$authenticated_id}{}{0}{${if eq {$sender_address}{$local_part@$domain}{0}{${if match{$received_protocol}{N^e?smtps?a$N}{${perl{checkbx_autowhitelist}{$authenticated_id}}}{${if eq{$received_prot
  • Firefox 11 closes/quits without saving Open Tabs Prompt Solution/Fix
  • Firefox 11 stop hiding http:// and https:// solution fix
  • The Importance of a High Quality Power Supply/Power Supplies To Prevent Overheating/System Crash/Hardware Damage
  • Asus VE247H 23.7" Inch LCD/LED Backlit Monitor Dead/Stuck Pixel Policy Complaint
  • Firefox Error ./firefox-bin: error while loading shared libraries: libxul.so: cannot open shared object file: No such file or directory
  • Linux Ubuntu Nvidia GT430 Lockups/Errors/Freezes NVRM: os_schedule: Attempted to yield the CPU while in atomic or interrupt context
  • Xen how to mount disk images off-line and access data
  • Xen non-HVM container won't work/boot anymore
  • how to exit xen console session from xm
  • Skype Linux/Ubuntu Sound Echo/Distortion Poor Quality Problem Fix Solution
  • Ubuntu 10.04 Flash Videos have tearing/lines Solution
  • File /etc/vz/conf/ve-vps.basic.conf-sample not found: No such file or directory - Openvz Error solution
  • Ubuntu 10 Nvidia Drivers Not Updated After Kernel Update Solution/How-To Manually Rebuild nvidia kernel modules for Ubuntu
  • What's Needed To Fix Linux