By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,043 Members | 663 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,043 IT Pros & Developers. It's quick & easy.

set text input value onclick etc

P: 35
Hi,

Its something stupidly simple but for some reason i cant find a straight forward cross browser solution.

I've got 2 sets of address fields and i want a tick box that when the user clicks it populates the 2nd lot of boxes with the values in the first.

I had it working in I.E ok using the following;

Expand|Select|Wrap|Line Numbers
  1. document.getElementById("inputid2").value=document.getElementById("inputid1").value;
But it doesn't seem to be working in chrome.....im guessing it must need referencing in a different way.

Does anyone have a straight forward cross browser method for setting various input values.

Thanks
Jan 5 '11 #1
Share this Question
Share on Google+
4 Replies

Dormilich
Expert Mod 5K+
P: 8,639
do the input fields actually have an id?
Jan 5 '11 #2

P: 35
I've actually just checked again and its not working at all(any browser)....the input definitely has an id set.

even this document.getElementById("fnameb").value="test";
doesnt work....fnameb is the id.

any reason why that wouldnt work?
Jan 5 '11 #3

Dormilich
Expert Mod 5K+
P: 8,639
I would need to see the page to make a qualified judgement.
Jan 5 '11 #4

Samishii23
100+
P: 246
If you have Chrome go to the little Wrench icon in the upper-right (Below the minimize / max / close buttons), then go to Tools, then Javascript Console. It'll give you error messages there, and if it helps you great, if not it could help us help you.

Oh and posting your exact code would help too, or link.
Jan 6 '11 #5

Post your reply

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