469,609 Members | 1,230 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

Display values in input text box on clicking link in popup window

Hi all,
I am creating a web page using ASP and JavaScript.
In my page i have an entry form which asks the user to enter details like their name , age,platform,language....... etc.
Near the input box of language i have link which opens a seperate window....
In that window i have the details of the code no and languages
like 1 C
2 C++ etc...... which i get from the database and display in the window.

Now i have create the same in link which when i clik shd displayed in the text box
Sep 21 '07 #1
5 2555
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

I've changed the thread title to better describe the problem.

Post what code you have so far.

To access the parent window, use window.opener.
Sep 21 '07 #2
Hi


Expand|Select|Wrap|Line Numbers
  1.  <td>&nbsp;&nbsp;
  2. &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;
  3. &nbsp;&nbsp;<span style="font-weight: bold;">Languages
  4. &nbsp;</span> &nbsp; &nbsp; &nbsp; &nbsp;
  5. &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<input
  6.  name="lang_id" id="langid" maxlength="25"
  7.  size="25" type="text">&nbsp;&nbsp;<a
  8.  href="javascript:open()">Details</a></td>
  9.                                           <td><a
  10.  href="javascript:open_win()"><br>
  11.                                           </a></td>


In JS file
it will open the window and display the details
Expand|Select|Wrap|Line Numbers
  1. function open()
  2. {
  3. window.open("Open.asp","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=320, height=400")
  4. }
  5.  
In Open.asp
Just to display the values in the table.

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim tt_Connection
  3. Dim tt_Recordset
  4. Dim counter
  5. counter=0
  6. Set tt_Connection = Server.CreateObject("ADODB.Connection")
  7. Set tt_Recordset = Server.CreateObject("ADODB.Recordset")
  8. tt_Connection.Open "DRIVER={MySQL ODBC 3.51 Driver};SERVER`=localhost;PORT=3306;DATABASE=table1;USER=root;PASSWORD=pass;OPTION=3;" 
  9. tt_Recordset.ActiveConnection = tt_Connection    
  10. tt_Recordset.open "Select Language_ID,Language from table1",tt_Connection
  11.  Response.Write "<table class='SearchTable' border='3' cellpadding='2' cellspacing='2' width='100%'>" &_
  12.                                                            "<tbody> <tr>"
  13.                                                    While (counter < tt_Recordset.fields.Count )
  14.                                                          Response.Write "<td><b>" & tt_Recordset.fields(counter).Name & "</b></td>"  
  15.                                                          counter = counter + 1
  16.                                                      Wend
  17.                                                      counter = 0
  18.                                                      Response.Write "</tr> <tr>"
  19.                             While Not tt_Recordset.EOF
  20.                                  While (counter < tt_Recordset.fields.Count )
  21.                                            Response.Write "<td>" & tt_Recordset.fields(counter).Value & "</td>"
  22.                                            counter = counter + 1
  23.                                      Wend
  24.                                      Response.Write "</tr>"
  25.                                  tt_Recordset.MoveNext
  26.                                  counter = 0
  27.                             Wend
  28.                                                    Response.Write "</tbody></table>"
  29. %>
  30.  


I have finished till display. Now my task is to display the Language_ID in the textbox, which id i am selecting from the table.... Also it shd be in A href. I don knw how to proceed... pls help me...


Thanks
Sep 24 '07 #3
acoder
16,027 Expert Mod 8TB
On line 21 in Open.asp, change it to something like:
Expand|Select|Wrap|Line Numbers
  1. Response.Write "<td><a href='#' onclick='setVal(\"" & tt_Recordset.fields(counter).Value & "\"); return false;'>" & tt_Recordset.fields(counter).Value & "</a></td>"
Then the function setVal could be:
Expand|Select|Wrap|Line Numbers
  1. function setVal(val) {
  2.  window.opener.document.getElementById("langid").value = val;
  3. }
PS. remember to use code tags when posting code:
[CODE=javascript]
Javascript code here...
[/code]
Sep 24 '07 #4
On line 21 in Open.asp, change it to something like:
Expand|Select|Wrap|Line Numbers
  1. Response.Write "<td><a href='#' onclick='setVal(\"" & tt_Recordset.fields(counter).Value & "\"); return false;'>" & tt_Recordset.fields(counter).Value & "</a></td>"
Then the function setVal could be:
Expand|Select|Wrap|Line Numbers
  1. function setVal(val) {
  2.  window.opener.document.getElementById("langid").value = val;
  3. }
PS. remember to use code tags when posting code:
Expand|Select|Wrap|Line Numbers
  1. Javascript code here...
  2.  



Hi Acoder,
Thanks a lot.....
And it is working fine........
Thanks a lot for ur timely help.....


Also just give me an idea as how to trigger a mail when we made a change in database


Thank U .... thanks a lot....
Sep 24 '07 #5
acoder
16,027 Expert Mod 8TB
Glad to hear you got it working.
Also just give me an idea as how to trigger a mail when we made a change in database
Why not just use the script which makes the change to send the mail?
Sep 24 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by jackson2005 | last post: by
1 post views Thread by colleen1980 | last post: by
5 posts views Thread by kosta.triantafillou | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.