NameSilo

A text field link?

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
Watch
Impact
0
Hello,

I've been designing simple websites for about a year, and I'm just beginning to create some more complex sites. I have a question. A client of mine would like to have an area on his site where a user could enter a pin# and download a document.

Here's what I would like to do (if it's possible):
I would like to create a text field that a user can enter a pin# and click go. This would link to a document. The pin# entered would be the same name as the document. This way, my client can upload documents named after the pin number he chooses for his individual clients, and no other intervention would be required.

Example:

the user would enter "1234" and click go. somehow, the 1234 would be renamed "1234.doc", or "1234.htm" and be opened.

Is this possible without using asp or php? My client is using a free hosting service that doesn't include these.

Thanks for the help!
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains โ€” AI StorefrontUnstoppable Domains โ€” AI Storefront
you can put this between the <head> tags

<script language="javascript">
function getFile(aForm){
var path = "path_to_docs"
var fname = path + aForm.file.value + ".doc";
window.open(fname);
}
</script>

and in the form tag add

onSubmit="getFile(form1)"

name the text field file

If the file is not there, then the window will come up not found.

This is a quick and dirty way to do it with jscript
 
0
•••
You can also do this with PHP, by using a variable for the inputted number.
 
0
•••
hmmm, not working

I tried it, and it didn't work. I'm doing something wrong. I don't fully understand code, and I'm pretty sure I'm missing something.

Here's what I have:

I already had some other rollover scripts between the head tags, so I just added this one below them.

function getFile(aForm){
var path = "/reports"
var fname = path + aForm.file.value + ".doc";
window.open(fname);
}
</script>

And this is my form code:

<form name="form1">
<input type="text" name="file">
<input type="submit" name="submit" value="Download" onSubmit="getFile(form1)">
</form>

But when I click on the submit button, it just refreshes the page.

Any suggestions?

Thanks!
 
0
•••
I figured it out a little more

ok, I found my mistake. I put the "onsubmit" in the wrong place.

Now it works, and the document downloads just fine, but after you click download and get the document, an error message appears in the browser window. I attached part of a screenshot of what it says.

Any suggestions on how to get it to go back to page with the pin# entry?
 
0
•••
Inside the form tag add

action="page you want it to go to"

and it should work.
 
0
•••
still doesn't work

nope, it still doesn't go there. I get the same exact error as before.
 
0
•••
post up your code for the form
 
0
•••
this is in the head:

function getFile(aForm){
var path = "http://www.wmpis.com/reports/"
var fname = path + aForm.file.value + ".doc";
window.open(fname);
}

and here is the form tag:

<form name="form1" method="post" onSubmit="getFile(form1)" action="http://www.wmpis.com/report.htm">
<input type="text" name="file">
<input type="submit" name="Submit" value="Download">
</form>
 
0
•••
Hello

Seems that your page doesn't allow the post method.

so try this

<form name="form1">
<input type="text" name="file">
<input type="button" name="Download" value="Download" onClick="getFile(form1)">
</form>

this should work.
 
0
•••
Thank you! It's working now. Little by little I'm learning.

Thanks Again!
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
Truehost โ€” .com domains from $4.99, hosting includedTruehost โ€” .com domains from $4.99, hosting included
Escrow.com
Spaceship
Domain Recover
CryptoExchange.com
Catchy
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back