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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pop-up to send information back to page ? 1

Status
Not open for further replies.

Gatchaman

Programmer
Jan 21, 2003
71
0
0
AU
Hey all, I have a query.

I have a page with an input box on it with a button right after it.

The input box will have to hold a file name, but I only want the user to be able to enter the name of a file that is in a certain directory. So, what I've done is when they click a button it opens a pop-up with some ASP code in it to display all the files in the particular directory, each of which are a hyperlink.

What I would like to do is make it so that when the user clicks on the hyperlink for a picture, I want the pop-up to close and the name of the file put into the text-box on the main page.

Just wondering if this is possible, and if so if someone could point me in the direction of how to go about it.

Thanks in advance for any help/ideas.

Damon
 
code in POP-UP window (findfile.asp)--
<script>
function go(f_name)
{
window.parent.opener.div_file.innerHTML = '<font color=&quot;#0000c0&quot;>'+f_name+'</font>';
window.top.close();
}
</script>

Response.Write &quot;<TD width=200 align =left><a style=&quot;&quot;cursor:hand&quot;&quot; onclick=&quot;&quot;javascript: go('&quot;&fname&&quot;');&quot;&quot;><font face=arial size=1>&quot;&URL&&quot; </font></a></TD>&quot; & vbcrlf

Code in main window --


<html>
...
<table><tr>
<td colspan=&quot;4&quot; width=&quot;330&quot; style=&quot;cursor:hand&quot; bgcolor=&quot;#E0E0E0&quot; onclick=&quot;javascript: findfile()&quot; >
<div id=&quot;div_file&quot; name=&quot;div_file&quot; width=&quot;80%&quot;> </div></td>
</tr></table>
 
Gatchaman,

Here's a sample I used to build a variety of pop-up form-fillers:

save this as &quot;Sample.html&quot;:

Code:
<!DOCTYPE html 
     PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
     &quot;[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>[/URL]

<html xmlns=&quot;[URL unfurl="true"]http://www.w3.org/1999/xhtml&quot;[/URL] xml:lang=&quot;en&quot; lang=&quot;en&quot;>
  <head>
    <meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;></meta>
    <title>JavaScript Sample</title>
    <script src=&quot;Sample.js&quot; type=&quot;text/javascript&quot;></script>
  </head>
  <body>
    <form name=&quot;MainForm&quot;>
      <input type=&quot;button&quot; value=&quot;Add...&quot; onclick=&quot;Warning('open');return false;&quot;></input>
      <p>Question<br /><textarea cols=&quot;40&quot; rows=&quot;2&quot; name=&quot;Question&quot; id=&quot;Question&quot;></textarea></p>
      <p>Answer<br /><textarea cols=&quot;40&quot; rows=&quot;2&quot; name=&quot;Answer&quot; id=&quot;Answer&quot;></textarea></p>
    </form>
  </body>
</html>

Save this as &quot;NewQA.html&quot;:

Code:
<!DOCTYPE html 
     PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
     &quot;[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>[/URL]

<html xmlns=&quot;[URL unfurl="true"]http://www.w3.org/1999/xhtml&quot;[/URL] xml:lang=&quot;en&quot; lang=&quot;en&quot;>
  <head>
    <meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;></meta>
    <title>Add a Question</title>
  </head>
  <body bgcolor=&quot;#ddddff&quot;>
    <p><b>Add New Question</b></p>
    <form name=&quot;Formie&quot;>
      <p>Question<br /><textarea cols=&quot;40&quot; rows=&quot;2&quot; name=&quot;Question&quot; id=&quot;Question&quot;></textarea></p>
      <p>Answer<br /><textarea cols=&quot;40&quot; rows=&quot;10&quot; name=&quot;Answer&quot; id=&quot;Answer&quot;></textarea></p>
      <p><input type=&quot;button&quot; value=&quot;Cancel&quot; onclick=&quot;window.close();&quot;></input> <input type=&quot;button&quot; value=&quot;Clear Entries&quot; onclick=&quot;Question.value='';Answer.value=''&quot;></input> <input type=&quot;button&quot; value=&quot;Accept Entries&quot; onclick=&quot;window.opener.document.MainForm.Question.value=Formie.Question.value; window.opener.document.MainForm.Answer.value=Formie.Answer.value; window.close();&quot;></input></p>
    </form>
  </body>
</html>

And save this as &quot;Sample.js&quot;:

Code:
function Warning(Argument)
  {
    if(Argument==&quot;open&quot;)
      {
        Win_Warning = window.open('NewQA.html','Win_Warning','top=50,screenY=50,left=50,width=365,height=400,scrollbars=no,scrollbar=no,menubar=no');
      }

    if(Argument==&quot;close&quot;)
      {
        if (Win_Warning.closed+&quot;&quot; == &quot;false&quot;)
          {
            Win_Warning.close();
          }
        else
          {
          }
      }
  }

The rest is filling out what you need different.

Hope that helps.

Cheers,

Edward &quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Hi, I'm sorry to say this, but I'm unable to work out what either of you are doing in your examples.

I don't really understand how you to use your page Edward, could you please explain what I have to do ?

Thanks
 
Oops, nevermind Edward, I misread, it's supposed to be 3 pages, not 2, I missed the part about saving as NewQA.html.

Works great, thanks for your help :)

a Star for you,

Damon
 
oooh, thanks!

cheers,

Edward &quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top