-1

I am trying to make a download button, however, when the button is clicked, I want the button value to say "File Downloaded". For some reason the file does not download... Someone once told me everything is possible in Web Development

My Current Code:

<li><input onclick="this.value='File Downloaded'" href="DP_1tahoe.rbxm" download="DP_2018 Tahoe.rbxm" type="button" value="Download" id="myButton1" /></li>

Please correct my code, thank you so much

MrDev
  • 1
  • 2
  • After changing button text you can download file with javascript in new window, button has no href attribute https://stackoverflow.com/a/18676770/10634638 – estinamir Jul 01 '21 at 23:24

1 Answers1

1

try this its working

<form name="form" id="form" onsubmit="return false">
    <button name="button" id="button" onclick="changeValue();" value="Download">Click Me!</button>
</form>

<script type="text/javascript">
    function changeValue()
    {
        console.log(document.form.button.value);
        // Changes the value of the button
        document.form.button.value='File Downloaded';
        console.log(document.form.button.value);
    }
</script>
iliyass
  • 136
  • 1
  • 5