469,289 Members | 2,192 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,289 developers. It's quick & easy.

Copying cell contents (text) into an input field

Hi Everyone,

I am creating a search facility that holds titles and SKU numbers. When the results appear in a 2 column table I would like the title to go into an input (readonly) field and the SKU to go into a different input field. I have the code below to help visualise what I am trying to do.

I think what I want is similar to a calendar where you can select the date you want and it appears in an input field - this I can do, but can't figure out how to do simple text.

I would also like to do the opposite - Typing into an input field and the text appearing into a table cell.

I hope that makes sense, any help would be great.

HTML doc

[HTML]<body>
<tr>
<td>
Title<br>
<input name="title" type="text" size="55" readonly="true">
<a href="javascript:void" onClick="window.open('search.html','window', 'width=550, height=610, scrollbars=1')">Go</a>
</td>
</tr>

<tr>
<td>
SKU<br>
<input name="sku" type="text" size="55" readonly="true">
<a href="javascript:void" onClick="window.open('search.html','window', 'width=550, height=610, scrollbars=1')">Go</a>
</td>
</tr>
</body>
[/HTML]
Search HTML doc (search.html)

[HTML]<table width="200">
<tr>
<td>Hello</td>
<td>FSDU/789789/0408</td>
</tr>
</table>
[/HTML]
Thank you
Mar 26 '08 #1
1 1282
acoder
16,027 Expert Mod 8TB
Give your input elements IDs so you can easily refer to them.

To refer to the parent window from the child (search) window, use window.opener. So, to change the value of the input field, use
Expand|Select|Wrap|Line Numbers
  1. // assuming you have the value 
  2. window.opener.document.getElementById("title").value = val;
If you need more hints, let me know.
Mar 26 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

12 posts views Thread by Adam Lipscombe | last post: by
1 post views Thread by Thanks | last post: by
2 posts views Thread by Maziar Aflatoun | last post: by
7 posts views Thread by Arne Beruldsen | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.