
May 15th, 2004, 05:50 PM
|
|
|
|
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152
Time spent in forums: < 1 sec
Reputation Power: 6
|
|
|
RE: Javascrript help
all you need to do is reference the value of the form field like so.
document.formname.fieldname.value
and assign it to a variable. The following example will show a popup alert of the field value of the input file type when you click the submit button.
<form method="post" name="form1">
<input type="file" enctype="multipart/form-data" name="file" />
<input type="submit" name="submit" value="Submit" onclick="alert(document.form1.file.value);return false;"/>
</form>
note the return false is there to actually prevent the form from being submitted for this example. If you put this code in a page and then browse for a file, then click the submit button, the popup will show the file selected. This method can be used for any form field.
|