CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Mar 2013
    Posts
    1

    Unhappy Function for Input Boxes

    Hi,

    Summary of task: Click on text, it appears in input box 1. Click on another text, it appears in box 2. Click again, box 3. If the first box has text in it, it will appear in the second, and so on.

    However in the function below, the text never goes to Box 3. I don't know how to fix it!


    Code:
    var hasbeenset = false;
    
    function setInput(id){
    if(hasbeenset)
    {
    document.getElementById("myinput2").value= id;
    }
    else if
    (hasbeenset=true)
    
    {
    document.getElementById("myinput").value=id;
    
    }
    else 
    
    {
    document.getElementById("myinput3").value=id;
    
    }
    
    
    }
    Attached Files Attached Files

  2. #2
    Join Date
    Aug 2011
    Location
    West Yorkshire, U.K.
    Posts
    54

    Re: Function for Input Boxes

    Err ... this is javascript not java !!!
    Your code might work better if you do something along the lines of: check if input 1 is blank (null or zero length string). If it is, set its contents to id, otherwise check if input 2 is blank. If it is, set its contents to id otherwise set input 3 contents to id.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured