Username:
Password:
Remember me:
Register

Back to forum: Web Programming (HTML, JS, CSS, PHP, MySQL)


Search forums via Google


0 Users appreciate this thread.

The hell am i doing wrong
Started by PLMasterSSB
(2014-08-05 00:09:58)
PLMasterSSB (2014-08-05 00:09:58)
<textarea id="cap_text"></textarea>
<script>
var cap_text = document.getElementById("cap_text".value;

alert(cap_text);
</script>
the alert window is empty even when I inputed text. i've done this before with other scripts and it worked. The hell am I doing wrong.
ryanb000977 (2014-08-05 03:09:38)
It's executing the code as soon as you load the page. Make it like the one below:
Source Code
<script> function showTxt() { var txt = document.getElementById("txt" ).value; alert(txt); } </script> <textarea id="txt"></textarea><br> <a href="#" onclick="showTxt()">Submit</a>


This post has been edited one or more times, the last time was:
2014-08-05 10:13:04

carlos11 (2014-08-05 09:46:36)
Simple. You forgot to add mayonnaise.
Language is a tool for efficient communication. The internet is a tool for fast communication. Do not defy both intents by posting incoherent writing.
PLMasterSSB (2014-08-05 13:33:05)
thx @ryanb000977. I forgot you had to put it in a function to execute. I haven't coded in a long time so I forgot that.
TheAlexRider (2014-08-05 20:27:17)
It needs function in it.
 

Log in to submit a comment

This topic's ID: 74033

Back to forum: Web Programming (HTML, JS, CSS, PHP, MySQL)




Total registered users: 8321
New registered users today: 7
Newest registered user: ElegantVulpes

©  Copyright 2026 3DSPlaza. All Rights Reserved