Refresh page when user clicks submit button (but theres a catch to this!)
Posted on 2006-04-21
hey guys and gals
I have a picture upload form page (done in coldfusion but I need JS help). As you will notice, upon clicking "Add Picture", it checks to see if the there is a picture file to upload. If not, it simply shoots an alert box telling the user to add a picture.
Another thing you will notice is that onClick of the submit button, the text on the button changes to "Please Wait".
That works fine.
Here is the issue: If a user clicks on the "Add Picture" button without adding a picture to upload, I recieve the alert box. When I close the alert box the text on the submit button says "Please Wait". I need this button to return to its original state of saying "Add Picture" when the user clicks ok on the alert box. Can anyone help me out?
My code is below.
function validate_form ( )
valid = true;
if ( document.upload_form.ul_path.value == "" )
alert ( "Please add a picture to upload." );
valid = false;
<cfform action="imUploadPictureForm.cfm?GameID=#ScheduleView.GameID#" method="post" name="upload_form" enctype="multipart/form-data" id="upload_form" onSubmit="return validate_form ( );">
<td><input type="file" name="ul_path" id="ul_path" size="50"></td>
<td><input type="submit" name="upload_now" value="Add Picture" onClick="this.value='Please Wait'"></td>