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 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2009
    Posts
    84
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Make a button change text when clicked?

    Hello,

    On my site i have a file uploader.

    PHP Code:
    <table align="center"class="table">

        <tr>
            <td class="table_header" colspan="2"><b><?=$websitename;?></b> </td>
        </tr>
        <tr>
            <td colspan="2" class="upload_info">
                <b>Allowed Types:</b> <?=$types?><br />
                <b>Max size per file:</b> <!--<?=$max_file_size?>-->50MB.<br />
                <b>Max size for all files combined:</b> <!--<?=$max_combined_size?>-->150MB.<br />
            </td>
        </tr>
        <?For($i=0;$i <= $file_uploads-1;$i++) {?>
            <tr>
                <td class="table_body" width="120%"><b>Select File:</b> </td>
                <td class="table_body" width="120%"><input type="file" name="file[]" size="30" /></td>
            </tr>
        <?}?>
        <tr>
            <td colspan="2" align="center" class="table_footer">
                <input type="hidden" name="submit" value="true" />
                <input type="submit" readonly value=" Upload File(s) " /> &nbsp;
                <input type="reset" name="reset" value=" Reset Form " /> &nbsp;

            </td>
        </tr>

        <tr>

    </table>
    What i want it to do is when they have clicked upload file(s) i want that to change to "your files are being uploaded" and make the button unclickable?

    im sure ive seen this done before and im sure its javascript.

    Thanksss all,
    James

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,300
    Thanks
    203
    Thanked 2,561 Times in 2,539 Posts
    Try this:-

    Code:
    <input type="submit" id = "but1" value=" Upload File(s)" onclick = "return dis()" /> &nbsp; 
    
    <script type = "text/javascript">
    
    var flag = 0;
    function dis() {
    document.getElementById("but1").value = "Your files are being uploaded";
    if (flag == 0) {
    flag = 1;
    return true;
    }
    else {return false}
    }
    
    </script>
    You could simply set the button to disabled = true, but then it is greyed out.


    "In the second half the tide turned completely on its head ........" - Football commentator

  • #3
    New Coder
    Join Date
    Jan 2009
    Posts
    84
    Thanks
    5
    Thanked 0 Times in 0 Posts
    could i make it so that it cant be clicked once pressed?

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,300
    Thanks
    203
    Thanked 2,561 Times in 2,539 Posts
    Quote Originally Posted by sphinx1994 View Post
    could i make it so that it cant be clicked once pressed?
    Yes, that it what is does. You can only click once (and subsequent clicks will return false).

  • #5
    New Coder
    Join Date
    Jan 2009
    Posts
    84
    Thanks
    5
    Thanked 0 Times in 0 Posts
    if i also wanted it to load a page in an iframe at the same time would i add it under
    Code:
    function dis() {
    the function that loads the iframe is
    Code:
    name="imageloader"
    so if i wanted to make it load, pleasewait.html

    ?

    Thanks


  •  

    Posting Permissions

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