View Single Post
Old 12-06-2009, 08:44 AM   PM User | #4
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
Your code works. No need to modify onChange to onchange in the html (although it's good practice to use all lowercase in html). Html is not case-sensitive unlike Javascript.

Code:
<html>
<head>
<script type="text/javascript">
function getNewValue(inputhidden, textinput) {
var data = document.getElementById(inputhidden);
var text = document.getElementById(textinput);
data.value = text.value;
}
</script>
<body>
<form>
<input type= "text" name= "name" id= "name" onChange="getNewValue('detail', 
'name')">
<input type= "hidden" name= "detail" id="detail" value= "">
</form>
</body>
</html>
After loading the page and typing something in the field, quickly verify that the hidden input's value changed by typing this in the browser's address bar and hitting Enter key:

Code:
javascript:alert(document.getElementById('detail').value)
It should alert the value entered in the 'name' field.
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Users who have thanked glenngv for this post:
oesxyl (12-06-2009)