How do I do a browse button, that when clicked on will just open the browse box, and store the link to the file in its value, I don’t want it to connect to any server or anything (so i’m not sure what to do for the action and method attributes…). Basically after the user browses for a file, they can click another button and an onclick event occurs, but when I try it, it’s not functioning properly.
<form action="" method="POST">
<input name="fileupload" id="fileupload" type="file">
<input value="OK" type="submit" onclick="change_bg_img('Untitled.png');">
</form>
You have an input of
type="submit". Clicking it will submit the form, so the JavaScript will run, then the page will reload in its default state.If you don’t want to ever submit the data to the server then:
<form>type="button"nottype="submit"