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

Quick Look-Up form and Return Value 1

Status
Not open for further replies.

ISPrincess

Programmer
Feb 22, 2002
318
US
I have a form requesting User Input - say last name.

so
Input type=text name=lastname

Next to that I would like a link / button / whatever so that they can do a quick last name look up.

Say the user knows that whomever they are trying to look-up's first name is "John" - but they do not know his last name.

This "Quick Look Up " link - or button or whatever - when clicked should open up a way for them to enter the First Name "John" on another form - or somewhere. When this is entered, this will then look up the first piece of data in a SQL Table where FirstName = "John" - it will then return the corresponding lastname value from the table onto the original from in the Last Name Input Box.

This should be very easy - but since I began working with another type of pop up screen which was all client-side - I have gotten myself alittle lost.

If anyone has any quick ideas, I would really appreciate it.

Thank you!
 
Hi ...
OK ...
you have to put a button or link in the first form to call a javascript that opens a new window in one of two method (window.open or window.dialogshowmodal)
then in that window you shuld have a code to get the first name and then search the DB and gives the lastname and then have another javascript in the new window to close itself and write the found lastname in the parent window.
now in you use the window.open, you have access to the parent window like this :
window.opener.all.item('myinput').value = something ;
and then use :
self.close() ; Or window.close() ;
but if you use window.dialogshowmodal, you have to use the parameter or the return value of the dialog.
because the window.open method is much more easyer, it's better for you to use this method.
----
TNX.
E.T.
 
Thanks - that is exactly what I am doing - but I am having a problem because I need to put the data access in client side script - I want to get it into server side and then still return the value to the parent form as you stated.

I have a post under the forum called "Unwanted client side data access" that I have not gotten any response on - but here is my page that would get the data. (not first name last name as in my example tho)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The following code is a page that needs to get a recordset on its ononload event - therefore it is client side data access via SQL.

I need help with this script (to be applied to others where I must load up my user's Excel - also client side script). Either I have the Monday morning brainlessness problem and I need help getting the results of the data query to server side or I need to disable the annoying question that our users' must answer 'yes' to in order to see the results - following:

This page is trying to access a data source on another domain. Do you wish to allow this?

Here is my code:


<%Response.Buffer = true%>

<%
Dim sLocation, sServer
sLocation = session(&quot;Location&quot;)
sServer = session(&quot;Server&quot;)
%>

<HTML>
<BODY bottomMargin=1 leftMargin=1 topMargin=1 rightMargin=1 bgColor=steelblue>
<SCRIPT LANGUAGE=VBSCRIPT>
Sub window_onunload
Dim rstReport
Dim sLocConnection
Dim sUID, sPWD, Params
Dim cnn

if document.All.location.value <> &quot;&quot; Then
sServer = document.All.srv.value
sLocation = document.All.loc.value

sUID = &quot;UID&quot;
sPWD = &quot;PWD&quot;
Params = document.All.Location.value

sLocConnection = &quot;Provider=SQEDB.1;server=&quot; & sServer & &quot;;database=&quot; & sLocation & &quot;;uid=&quot; & sUID & &quot;;pwd=&quot; & sPWD
Set cnn = createObject(&quot;Adodb.connection&quot;)
cnn.CursorLocation = 3 'adUseClient
cnn.CommandTimeout = 60
cnn.Open sLocConnection

Set rstReport = createobject(&quot;adodb.recordset&quot;)
set rstReport = cnn.Execute(&quot;exec rpt_GetLineName2 &quot; & params)
if not rstReport.EOF then document.All.LineName.value = rstReport.Fields(&quot;LineName&quot;)

window.returnvalue = document.All.LineName.value
end if


end sub
</SCRIPT>
<Center>
<BR><BR><BR>
Location Prefix: <INPUT style=&quot;WIDTH: 48px; HEIGHT: 22px&quot; size=6 id=Location>
</Center>
<INPUT Type=Hidden style=&quot;WIDTH: 48px; HEIGHT: 22px&quot; size=6 id=LineName>
<INPUT type=Hidden id=Loc name=Loc value=<%=sLocation%>>
<INPUT type=Hidden id=Srv name=Srv value=<%=sServer%>>

<BR>

<center><INPUT type=button value=&quot;OK&quot; onClick=window.close id=button1 name=button1></center>
</BODY>
</HTML>
 
Hi ...
but you are not allowed to access to server side objects and ... from client side scripts ...
so the only way that you don't get this message is to use another window and run your code in it and return the result from that window to the current form.
----
TNX.
E.T.
 
This IS the 'other window'.

This is being called from another form and this form returns the value &quot;linename' back to it.
 
Hi ...
OK ...
try this one :

<%Response.Buffer = true%>

<%
Dim sLocation, sServer
sLocation = session(&quot;Location&quot;)
sServer = session(&quot;Server&quot;)
%>

<script language=&quot;javascript&quot;>
function selfclose() {
window.returnvalue = document.All.LineName.value ;
self.close() ;
}
</script>

<HTML>
<BODY bottomMargin=1 leftMargin=1 topMargin=1 rightMargin=1 bgColor=steelblue>
<%
Dim rstReport
Dim sLocConnection
Dim sUID, sPWD, Params
Dim cnn

if document.All.location.value <> &quot;&quot; Then
sServer = document.All.srv.value
sLocation = document.All.loc.value

sUID = &quot;UID&quot;
sPWD = &quot;PWD&quot;
Params = document.All.Location.value

sLocConnection = &quot;Provider=SQEDB.1;server=&quot; & sServer & &quot;;database=&quot; & sLocation & &quot;;uid=&quot; & sUID & &quot;;pwd=&quot; & sPWD
Set cnn = createObject(&quot;Adodb.connection&quot;)
cnn.CursorLocation = 3 'adUseClient
cnn.CommandTimeout = 60
cnn.Open sLocConnection

Set rstReport = createobject(&quot;adodb.recordset&quot;)
set rstReport = cnn.Execute(&quot;exec rpt_GetLineName2 &quot; & params)
if not rstReport.EOF then
Response.Write &quot;<INPUT Type='Hidden' id='LineName' value='&quot; & rstReport.Fields(&quot;LineName&quot;) & &quot;'>&quot; & vbCrLf
End If
end if
%>
<Center>
<BR><BR><BR>
Location Prefix: <INPUT style=&quot;WIDTH: 48px; HEIGHT: 22px&quot; size=6 id=Location>
</Center>
<INPUT type=Hidden id=Loc name=Loc value=<%=sLocation%>>
<INPUT type=Hidden id=Srv name=Srv value=<%=sServer%>>

<BR>

<center><INPUT type=button value=&quot;OK&quot; onClick=&quot;javascript:selfclose();&quot; id=button1 name=button1></center>
</BODY>
</HTML>
----
TNX.
E.T.
 
Hi ...
Sorry ... that code was wrong ... try this one :

<%Response.Buffer = true%>

<%
Dim sLocation, sServer
sLocation = session(&quot;Location&quot;)
sServer = session(&quot;Server&quot;)
%>

<script language=&quot;javascript&quot;>
function selfclose() {
window.returnvalue = document.All.LineName.value ;
self.close() ;
}
</script>

<HTML>
<BODY bottomMargin=1 leftMargin=1 topMargin=1 rightMargin=1 bgColor=steelblue>
<%
Dim rstReport
Dim sLocConnection
Dim sUID, sPWD, Params
Dim cnn

sUID = &quot;UID&quot;
sPWD = &quot;PWD&quot;
Params = document.All.Location.value

sLocConnection = &quot;Provider=SQEDB.1;server=&quot; & sServer & &quot;;database=&quot; & sLocation & &quot;;uid=&quot; & sUID & &quot;;pwd=&quot; & sPWD
Set cnn = createObject(&quot;Adodb.connection&quot;)
cnn.CursorLocation = 3 'adUseClient
cnn.CommandTimeout = 60
cnn.Open sLocConnection

Set rstReport = createobject(&quot;adodb.recordset&quot;)
set rstReport = cnn.Execute(&quot;exec rpt_GetLineName2 &quot; & params)
if not rstReport.EOF then
Response.Write &quot;<INPUT Type='Hidden' id='LineName' value='&quot; & rstReport.Fields(&quot;LineName&quot;) & &quot;'>&quot; & vbCrLf
End If
%>
<Center>
<BR><BR><BR>
Location Prefix: <INPUT style=&quot;WIDTH: 48px; HEIGHT: 22px&quot; size=6 id=Location>
</Center>
<BR>

<center><INPUT type=button value=&quot;OK&quot; onClick=&quot;javascript:selfclose();&quot; id=button1 name=button1></center>
</BODY>
</HTML>
----
TNX.
E.T.
 
ehsant -

I havent had time to try the code you sent but I want to thank you for all your time and patience on this. I can't tell you how valuable it is and how much I appreciate it.

Since it looks like one of my 'big' problems is that I don't know a stitch of Java. Can you recommend any books or tutorials?

Thank you again!!
B-)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top