Disabling and enabling the form text fields

Discussion in 'JavaScript' started by ZeroOne, Jun 16, 2005.

  1. #1
    Can I make the form text fields disable and when click on text fields it change

    to enable.

    I try to do that but it not work :
    
    <SCRIPT LANGUAGE="JavaScript">
    function enable() {
    document.formname.textname.disabled=false;
    }
    </SCRIPT>
    
    <form name="formname" method="POST" action="">
    <input type="text" disabled size="10" name="textname" onclick="enable()">
    ....
    .
    
    
    Code (markup):
    my another question is if the name of the input text is array like :
    <input type="text" size="10" name="textname[]" >
    how i can deal with it in javascript code (document.formname.(here))

    Thanks :)
     
    ZeroOne, Jun 16, 2005 IP
  2. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <form>
    <input id="i1" type="text" size="10" name="textname" onclick="this.disabled = true">
    <input type="button" name="textname" value="toggle" onclick="this.form.i1.disabled = !this.form.i1.disabled">
    </form>


    J.D.
     
    J.D., Jun 16, 2005 IP