Disabled submit issues

Discussion in 'JavaScript' started by sacx13, Mar 30, 2006.

  1. #1
    I successfuly write a little javascript code to disable my submit button when is pressed, but I have a issue ... when the button is disabled I cannot get the value sendit by this button. Any suggestions ?
    
    <form action="xxx.php" method="POST" enctype="multipart/form-data" name="form1">
    <input type="text" size="64" name="yyy" ><br>
    <input type="submit" name="action" value="submit" onclick="return disableInput(this);">
    
    Code (markup):
    Java script is

    
    function disableInput(input)
    {
    input.disabled=true;
    }
    
    Code (markup):

     
    sacx13, Mar 30, 2006 IP
  2. sacx13

    sacx13 Active Member

    Messages:
    438
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    58
    #2
    It appears when you have a input of type submit disabled his value is also blanked. So I found another solution.

    I added a input hidden type named validation what we check every time when we click on submit. at first click we change the validation on true and we return false from function.

    
    function disableInput(input)
    {
    
    if (input.validation.value=="false")
    {
        input.validation.value="true";
        return true;
    }
    else
    return false;
    
    }
    [CODE]
    
    In html code I added a new field of type hidden:
    <input type="hidden" name="validation" value="false">
    and i changed the variable from disableInput to:
    disableInput(form1.document)
    
    Regards
    Adrian
    Code (markup):
     
    sacx13, Mar 30, 2006 IP