set text input value onclick etc

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ukfusion
    New Member
    • Sep 2007
    • 35

    set text input value onclick etc

    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;

    Code:
    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
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    do the input fields actually have an id?

    Comment

    • ukfusion
      New Member
      • Sep 2007
      • 35

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

      even this document.getEle mentById("fname b").value="test ";
      doesnt work....fnameb is the id.

      any reason why that wouldnt work?

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        I would need to see the page to make a qualified judgement.

        Comment

        • Samishii23
          New Member
          • Sep 2009
          • 246

          #5
          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.

          Comment

          Working...