Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Assigning values to form text/input boxes

    If I wanted to call a textbox in a form with a function, how could I do so? I can't for the life of me figure out how to assign a variable to one.

    I am trying to set up a form with text boxes for the user to input information and click the submit button. Once they do that, an alert box will pop up displaying the information they entered then I the information will be placed in another text box on the web page.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Do you mean something like this example?

    PHP Code:
    <script type="text/javascript">

    function 
    getInputValue(){

    inputValue=document.myform.t1.value

    if(inputValue==""){
    alert("Please enter some text")
    }
    else{
    alert(inputValue)
    }

    }

    </script>


    <form name="myform">
    <input type="text" name="t1" value="">
    <input type="button" value="Get Input Value" onclick="getInputValue()">
    </form> 
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.


  •  

    Posting Permissions

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