Hi im john from Portugal,
Im trying to use a INPUT TYPE TEXT field to read input data from users. I want that any user after inputing the data on the field, woud only have to press ENTER button on keyboard to make the data be called by a function inside the JS code. I don't want to use INPUT TYPE BUTTON or OnKeyup function to do the same. I tried to do this with FORMS, here is a sample of my code:
----------------------------------------------------------------
<script>
var all, txt, btn, txtarea;
function init(){
txt = document.getElementById("txt");
btn = document.getElementById("btn");
all = document.getElementById("all");
txtarea = document.getElementById("txtarea");
}
function teste() { alert(all.txt.value); }
function mult(x){
x= x*2;
alert(x);
return txtarea.value = x;
}
</script>
<body onload="init();">
<form id="all" onSubmit='mult(all.txt.value)'>
<input type="text" id="txt" />
<br/>
<input type="button" id="btn" onclick='teste()' value=http://www.webdeveloper.com/forum/archive/index.php/"?"/>
</form>
<textarea id="txtarea"></textarea>
</body>
---------------------------------------------------------------
This code is an example of what im trying to do, this code reads the data from the input field and multiplys it by 2, after that it shows the result on alert POPUp window and TEXTAREA.
The alert popUp windows are working fine, what doesn't work is the TEXTAREA.
PLEASE HELP!
Im trying to use a INPUT TYPE TEXT field to read input data from users. I want that any user after inputing the data on the field, woud only have to press ENTER button on keyboard to make the data be called by a function inside the JS code. I don't want to use INPUT TYPE BUTTON or OnKeyup function to do the same. I tried to do this with FORMS, here is a sample of my code:
----------------------------------------------------------------
<script>
var all, txt, btn, txtarea;
function init(){
txt = document.getElementById("txt");
btn = document.getElementById("btn");
all = document.getElementById("all");
txtarea = document.getElementById("txtarea");
}
function teste() { alert(all.txt.value); }
function mult(x){
x= x*2;
alert(x);
return txtarea.value = x;
}
</script>
<body onload="init();">
<form id="all" onSubmit='mult(all.txt.value)'>
<input type="text" id="txt" />
<br/>
<input type="button" id="btn" onclick='teste()' value=http://www.webdeveloper.com/forum/archive/index.php/"?"/>
</form>
<textarea id="txtarea"></textarea>
</body>
---------------------------------------------------------------
This code is an example of what im trying to do, this code reads the data from the input field and multiplys it by 2, after that it shows the result on alert POPUp window and TEXTAREA.
The alert popUp windows are working fine, what doesn't work is the TEXTAREA.
PLEASE HELP!