Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #13422 > unrolled thread
| Started by | jbasemvd@gmail.com |
|---|---|
| First post | 2012-04-17 07:43 -0700 |
| Last post | 2012-04-17 08:08 -0700 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.javascript
getElementById assistance needed. jbasemvd@gmail.com - 2012-04-17 07:43 -0700
Re: getElementById assistance needed. Martin Honnen <mahotrash@yahoo.de> - 2012-04-17 16:58 +0200
Re: getElementById assistance needed. jbasemvd@gmail.com - 2012-04-17 08:08 -0700
| From | jbasemvd@gmail.com |
|---|---|
| Date | 2012-04-17 07:43 -0700 |
| Subject | getElementById assistance needed. |
| Message-ID | <12337143.309.1334673816427.JavaMail.geo-discussion-forums@ynhh34> |
Can someone tell me why this doesn't copy the text from one input to the other when the second input box is clicked? Thanks in advance.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
<link rel="stylesheet" type="text/css" href="StyleSheet1.css" />
<script type="text/javascript">
function getValue()
{
var x=document.getElementById("txtHere");
var y=document.getElementById("txtThere");
y.innerHTML = x.innerHTML;
}
</script>
</head>
<body>
<table class="basicTable" id="table1">
<tr>
<td><label for=here>Here</label></td><td><label for=there>There</label></td>
</tr>
<tr>
<td><input class="normal" id="txtHere" type="text" /></td><td><input class="normal" id="txtThere" type="text" onclick="getValue()"/></td>
</tr>
<tr>
<td><input class="basicButton" id="submit" type="submit" value="Submit" /></td>
</tr>
</table>
</body>
</html>
[toc] | [next] | [standalone]
| From | Martin Honnen <mahotrash@yahoo.de> |
|---|---|
| Date | 2012-04-17 16:58 +0200 |
| Message-ID | <4f8d850c$0$7623$9b4e6d93@newsspool1.arcor-online.net> |
| In reply to | #13422 |
jbasemvd@gmail.com wrote:
> Can someone tell me why this doesn't copy the text from one input to the other when the second input box is clicked? Thanks in advance.
> function getValue()
> {
> var x=document.getElementById("txtHere");
> var y=document.getElementById("txtThere");
> y.innerHTML = x.innerHTML;
> }
> <td><input class="normal" id="txtHere" type="text" /></td><td><input class="normal" id="txtThere" type="text" onclick="getValue()"/></td>
> </tr>
Well the innerHTML of empty elements (and input elements are by
definition empty) is the empty string.
You might want to set the "value" property of the input control instead
y.value = x.value;
--
Martin Honnen --- MVP Data Platform Development
http://msmvps.com/blogs/martin_honnen/
[toc] | [prev] | [next] | [standalone]
| From | jbasemvd@gmail.com |
|---|---|
| Date | 2012-04-17 08:08 -0700 |
| Message-ID | <16191939.363.1334675301752.JavaMail.geo-discussion-forums@ynmm10> |
| In reply to | #13423 |
Martin, That's perfect. Thanks.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web