Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

paste

Status
Not open for further replies.

passertm

Programmer
Aug 2, 2005
16
AZ
<html>
<body>

<form name=f>
<input name=op1>
<input type=file name=op2>

</form>

<script language=javascript>
f.op1.value='qwert';
f.op1.focus();
</script>

<input type=submit onclick="javascript:f.op1.focus();paste();">

</body>
</html>

i need creat a new html page with initial value of file field.
how to do that????
 
i need creat a new html page

Do you mean you want to pop open a new window? Or submit the form to a new page?

If the latter, you'll need to give your form an action, and then you could use server-side code to pick up on the value, and deliver it back to a page.

If you have no server-side scripting available to you, you could use the get method, and then scrape the URL with client-side JavaScipt... although this is not recommended, as people with no JS won't be able to use your site. Then again, from the example code you've shown above, I doubt this is for anything serious at all.

Hope this helps,
Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
I just need a page with the file field(<input type=file) that has a value
 
Well you don't need any code other than what you have. You alresady have a page, with an input of type "file"... and when the user puts something in it, it has a value.

Or... if that is not what you meant, maybe you can describe your needs a bit further?

Hope this helps,
Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
but i need file field with initial value.
something like:
<input type=file name=file1 value='c:\01.jpg'>
 
You need to provide a relative or absolute path... and it needs to be url encoded:
Code:
<input type="file" name="file1" value="c:%5C01.jpg"/>
Some details about encoding (including an online url encoding converter) are available here:
Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
<input type="file" name="file1" value="c:%5C01.jpg"/>

but it is not working

browser create it like
<input type="file" name="file1">
 
but it is not working
I am assuming that you are using Windows and that you have a file called 01.jpg sitting at the top level of your C drive. Since the example I gave sets the path for c:\01.jpg

The browser is obviousl putting in a relative URL. What happens if you put in a relative URL for your own code?

Maybe you should post us a URL or some more information about what you mean by "not working".

Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
You cannot set the inital value of a file input like that. It is a HUGE security risk. Imagine what you could do if this were possible.

You can use an outerHTML hack, I believe, to do this in IE... but not sure how cross-browser it is.

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top