...

View Full Version : Make a button change text when clicked?



sphinx1994
06-16-2009, 05:15 PM
Hello,

On my site i have a file uploader.


<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

Philip M
06-16-2009, 05:46 PM
Try this:-


<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

sphinx1994
06-16-2009, 05:51 PM
could i make it so that it cant be clicked once pressed?

Philip M
06-16-2009, 06:05 PM
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).

sphinx1994
06-16-2009, 06:13 PM
if i also wanted it to load a page in an iframe at the same time would i add it under
function dis() {


the function that loads the iframe is
name="imageloader" so if i wanted to make it load, pleasewait.html

?

Thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum