You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by murukesh radhakrishnan <mu...@yahoo.co.uk> on 2004/11/07 16:57:12 UTC

clearing the content of the file upload control

Hi all,

i have a file upload control in my jsp.Next to that control i have a

one more button with label clear attachment.

on clicking on that clear attachment button, i have to clear the

content of the file upload  textbox...is there any way by which i can

clear the content of the file upload  using javascript.

Regards

Murukesh


		
---------------------------------
 ALL-NEW Yahoo! Messenger - all new features - even more fun!  

Re: clearing the content of the file upload control

Posted by Erik Weber <er...@mindspring.com>.
<html:reset onclick="return 
clearAllFormFields(this.form);"><bean:message 
key="myClearButtonLabel"/></html:reset>

. . .

<script language="JavaScript">
                  function clearAllFormFields(form) {
                    for (var x = 0; x < form.length; x++) {
                      var current = form.elements[x];
                      if (current.type == "text") {
                        current.value = "";
                      }
                      else if (current.type == "select-one") {
                        current.selectedIndex = 0;
                      }
                      else if (current.type == "file") {
                        current.value = "";
                      }
                      else if (current.type == "textarea") {
                        current.value = "";
                      }
                      else if (current.type == "checkbox") {
                        current.checked = 0;
                      }  
                    }
                    return false;
                  }
                </script>



Erik



Koushik wrote:

>make that button <html:reset>
>and in ur form bean u have to write a reset() method where u set to that
>text field property to null
>hope it solves ur problem
>----- Original Message -----
>From: "murukesh radhakrishnan" <mu...@yahoo.co.uk>
>To: <st...@jakarta.apache.org>
>Sent: Sunday, November 07, 2004 9:27 PM
>Subject: clearing the content of the file upload control
>
>
>  
>
>>Hi all,
>>
>>i have a file upload control in my jsp.Next to that control i have a
>>
>>one more button with label clear attachment.
>>
>>on clicking on that clear attachment button, i have to clear the
>>
>>content of the file upload  textbox...is there any way by which i can
>>
>>clear the content of the file upload  using javascript.
>>
>>Regards
>>
>>Murukesh
>>
>>
>>
>>---------------------------------
>> ALL-NEW Yahoo! Messenger - all new features - even more fun!
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: clearing the content of the file upload control

Posted by Koushik <ko...@ontrackindia.com>.
make that button <html:reset>
and in ur form bean u have to write a reset() method where u set to that
text field property to null
hope it solves ur problem
----- Original Message -----
From: "murukesh radhakrishnan" <mu...@yahoo.co.uk>
To: <st...@jakarta.apache.org>
Sent: Sunday, November 07, 2004 9:27 PM
Subject: clearing the content of the file upload control


>
> Hi all,
>
> i have a file upload control in my jsp.Next to that control i have a
>
> one more button with label clear attachment.
>
> on clicking on that clear attachment button, i have to clear the
>
> content of the file upload  textbox...is there any way by which i can
>
> clear the content of the file upload  using javascript.
>
> Regards
>
> Murukesh
>
>
>
> ---------------------------------
>  ALL-NEW Yahoo! Messenger - all new features - even more fun!


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org