Modify readonly textfields

Discussion in 'PHP' started by lost, Dec 14, 2005.

  1. #1
    I have a form with a number of readonly textfields and a button called "modify". On click of the "modify" button, I need to change all the textfields to be editable.
    Can anyone help me with this one?

    i currantly have a loop that creates the readonly textfields like this:
    
    .
    .
    .
    while($rows = @mysql_fetch_array($result))
    {
       $index++;
       extract($rows);
    
       $desvalue = $rows['description']; 
       $pnovalue = $rows['partno']; 
    
       echo '<TR><TD><INPUT TYPE="text" READONLY=true NAME="description 1" VALUE="'.$desvalue.'">';
       echo '<INPUT TYPE="text" READONLY=true NAME="partno 1" VALUE="'.$pnovalue.'"></TD></TR>';
    
    }
    
    PHP:
     
    lost, Dec 14, 2005 IP
  2. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #2
    much easier to create a javascript function in the header section of your page that disables all text fields in the form by refering to the dom object hierarchy.

    then for the action of the button in the form, refer to the javascript function - using the onClick event...
     
    daboss, Dec 14, 2005 IP
  3. lost

    lost Peon

    Messages:
    144
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks daboss. If i understand correctly, do you mean something like this:

    This is the 'modify' button:

    
    <INPUT TYPE=button VALUE="Modify Existing Item" NAME="modifyconfigbutton" ONCLICK=modifyItems();>       
    
    HTML:
    THis is the javascript method:

    
      function modifyItems()
      {     
         loadedDesFieldNames = document.getElementById("modifytextfields"); 
         loadedDesFieldNames.attributes.readonly = false;
      }
    
    Code (markup):
     
    lost, Dec 14, 2005 IP
  4. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #4
    does it work? :)
     
    daboss, Dec 15, 2005 IP
  5. lost

    lost Peon

    Messages:
    144
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    NO :(

    Any ideas on how i can make it work???
     
    lost, Dec 15, 2005 IP
  6. jajA

    jajA Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    document.form1.textbox.readOnly = false;
     
    jajA, Sep 1, 2006 IP