Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Automatically copy file field contents to text field
Old 08-29-2006, 10:36 AM Automatically copy file field contents to text field
Average Talker

Posts: 29
Trades: 0
I have a PHP upload form, but i want the contents of the file field (containing the path to file being uploaded) to be automatically copied to another normal text field in the same form.

How can i do this?

Thanks alot
__________________
-ValC
ValC is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-29-2006, 11:35 AM Re: Automatically copy file field contents to text field
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
Like this?
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
		<title>Untitled Page</title>
		<script type="text/javascript"><!--
function showFileName(x) {
	document.FormName.textfieldName.value = x;
}
window.onload = function() {
	document.FormName.fileGetterName.onchange = function() {
		showFileName(this.value);
	}
}
//-->
</script>
	</head>

	<body bgcolor="#ffffff">
		<form id="FormName" action="" method="get" name="FormName">
			<input type="file" name="fileGetterName" size="16">
			<input type="text" name="textfieldName" size="35">
		</form>
	</body>

</html>

Last edited by funkdaddu; 08-29-2006 at 11:37 AM..
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 08-29-2006, 02:50 PM Re: Automatically copy file field contents to text field
Average Talker

Posts: 29
Trades: 0
Thanks alot!

This may be pushing my luck, but is there also a way to do the oposite? Automatically change the value in a file field by whats in a text field?

Appreciated.
__________________
-ValC

Last edited by ValC; 08-29-2006 at 03:00 PM..
ValC is offline
Reply With Quote
View Public Profile
 
Old 08-29-2006, 04:16 PM Re: Automatically copy file field contents to text field
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
Nope, via JS the file input's value is read only, AFAIK.
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Reply     « Reply to Automatically copy file field contents to text field
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23527 seconds with 12 queries