Question : show hide submit button with jquery

Hello,

How would I only display the submit button below when the user has selected a file to input in the file input control.  I want the submit button to remain hidden until the do select a file to input. I'm using jquery.

<form id="uploadFrm" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data">
                  <p>
                        <input type="file" name="image" id="image" size="50"/>
                        <input type="submit" name="submit" value="Upload" id="submit"/>
                  </p>                  
            </form>      

Answer : show hide submit button with jquery

Try this:

add this into your javascript code:

function showSubmit()
{
$('input[name=submit]').show();

}

and change your html to this

<form id="uploadFrm" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data">
                  <p>
                        <input type="file" name="image" id="image" size="50" onchange="showSubmit()"/>
                        <input style="display:none" type="submit" name="submit" value="Upload" id="submit"/>
                  </p>                  
            </form>      
Random Solutions  
 
programming4us programming4us