FORM Name="frmFile" How can I refresh the page that has this form?

Discussion in 'HTML & Website Design' started by tattoos, Oct 10, 2007.

  1. #1
    Hi all,
    I hope someone can help me figure this out.
    I have a form on a HTML page that fetches a file from another site when the text box is filled out and the download button is clicked,
    I would like to have the page that the form is on refresh after every click, But as yet I haven't been able to work out how to do it.
    The code I have is
    
    <FORM Name="frmFile">Enter number: <INPUT Type=Text Name="txtPath"><INPUT Type=Button onClick="document.location = 'http://www.my-other-site.com/media/files/' + frmFile.txtPath.value + '.zip'" Value="Download!"></FORM>
    Code (markup):
    So is there a way to get the form page to refresh? maybe before it calls the file? could I add the address of the page the form is on, to the start of the address where the file is located?

    something like,
    <FORM Name="frmFile">Enter number: <INPUT Type=Text Name="txtPath"><INPUT Type=Button onClick="document.location = <a href="http://www.mysite.com/index.html"</a> + 'http://www.myothersite.com/media/files/' + frmFile.txtPath.value + '.zip'" Value="Download!"></FORM>
    Code (markup):
    Or somthing like that:eek:... I know I suck at this sorta stuff.:eek:
    Any one have any ideas?
    TIA
    James
     
    tattoos, Oct 10, 2007 IP
  2. jBud

    jBud Peon

    Messages:
    387
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I'm not exactly sure what the submit call does but if you add an on mouseup event to the button it'll do the trick...
    For instance this will clear all form values as soon as the button is released, if you do it onClick there is a risk that the data will clear before it gets sent...
    anyway try this:
    <input name="button" type="button" value="Download" onClick="document.location = <a href="http://www.mysite.com/index.html"</a> + 'http://www.myothersite.com/media/files/' + frmFile.txtPath.value + '.zip'" onmouseup="document.frmFile.reset()" />
    Code (markup):
     
    jBud, Oct 10, 2007 IP
  3. tattoos

    tattoos Prominent Member

    Messages:
    1,903
    Likes Received:
    150
    Best Answers:
    0
    Trophy Points:
    335
    #3
    :) Cheers mate.. I will give that a go!
     
    tattoos, Oct 11, 2007 IP
  4. tattoos

    tattoos Prominent Member

    Messages:
    1,903
    Likes Received:
    150
    Best Answers:
    0
    Trophy Points:
    335
    #4
    After re-reading my first post, I couldn't really understand what I was asking :eek: so I think I should try and explain it a bit better...
    The submit call does this.. I have a heap of zips in a folder, randomly numbered. Instead of having a download link for each file I wanted to have just one link (the form)... so if the person knows what the number of the file they want is, they can type the number in to the form box and click download...
    So basically it calls the document.location which is http//www.example.com/media/files/ then adds the text path or the numbers they typed in, then adds the extension which is zip.
    So as an example.. if someone typed 1234 in the box it ends up being a link to http//www.example.com/media/files/1234.zip, the browser must see that it is a file and asks the person to open or save to disk etc, without moving away from the original page, (with the form on)..
    I added the onmouseup="document.frmFile.reset() to the form, but alas! like you said it would, it cleared all form values and then submitted.
    I am not sure what I can do here.. maybe I need it to open the link to the zip in a new window. (would that be, onClick="open.window()"document.location = etc?) but then I am still not sure how to refresh the original page with the form on :(
    I think if I try to add a refresh to the form it will try to refresh the link to the zip, therefore try and download the file twice... Arrgh I'm so confused
    Any input appreciated..
    James.
     
    tattoos, Oct 11, 2007 IP