TRACEYMARY
asked on
Using Javascript to pass back information into a drop downlist
I have managed to do the following:
<SCRIPT>
var sColor="";
function callDialog() {
showModelessDialog("testca llee.asp", window,"st atus:false ;dialogWid th:300px;d ialogHeigh t:150px");
}
function update() {
document.form1.oColor.valu e= sColor;
document.form1.aColor.valu e= sColor;
}
</SCRIPT>
Text Box
<input type="text" name="oColor" value="">
Search Button
<INPUT TYPE="button" VALUE="Search" onclick="callDialog()">
testcallee.asp
HTML>
<HEAD>
<TITLE>callee.html</TITLE>
<SCRIPT>
function getInfoAndUpdate() {
var callerWindowObj = dialogArguments;
callerWindowObj.sColor = oEnterColor.value;
callerWindowObj.update();
}
function cancel() {
var callerWindowObj = dialogArguments;
callerWindowObj.sColor = "Yellow";
callerWindowObj.update();
}
</SCRIPT>
</HEAD>
<BODY>
Enter your favorite color:<INPUT ID=oEnterColor><BR><BR>
<INPUT VALUE="Apply" TYPE=button onclick="getInfoAndUpdate( );">
<INPUT VALUE="Ok" TYPE=button onclick="getInfoAndUpdate( );window.c lose();">
<INPUT VALUE="Cancel" TYPE=button onclick="cancel();window.c lose();">
</BODY>
</HTML>
Now i would like to be able to return the value into a drop down list......
which i build from a database
<%Call CreateOption("AssetTag","s elect distinct ASSETTAG from ASSETTICKET WHERE ASSETTAG IS NOT NULL","ASSETTAG","ASSETTAG ", request("AssetTag"))%>
<%sub CreateOption(strName,strTa bleOrSQL,s trValue,st rDisplay, strSelected)
'This subroutine expects the following parameters:
' strName is the name of option to be created
' strTableNameOrSQL the name of table
' strValue is the field from the recordset that holds the value to be stored;
'strDisplay is the field from the recordset that will be displayed in the drop down;
'if a default value is to be selected, that is passed as strSelected. strJavaScript holds
'any event and script to be fired with that event.
dim objRSOption, strIsSelected
set objRSOption=Server.CreateO bject("ADO DB.RecordS et")
objRSOption.Open strTableOrSQL,dbConn
response.write("<Select Name = '" & strName & "'" & strJavaScript & ">")
response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & vbTab & "<Option Value = ''></Option>")
Do until objRSOption.eof
if Trim(UCase(objRSOption(str Value))) = Trim(UCase(strSelected)) then
strIsSelected = " selected"
else
strIsSelected = ""
end if
Response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & vbTab & "<Option" & strIsSelected & " Value ='" & objRSOption(strValue) & "'>" & objRSOption(strDisplay) & "</Option>")
objRSOption.MoveNext
Loop
Response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & "</Select>")
objRSOption.close
set objRSOption = Nothing
end sub%>
Possible.............to set the selected dropdown to the oColor coming in from the javascript
<SCRIPT>
var sColor="";
function callDialog() {
showModelessDialog("testca
}
function update() {
document.form1.oColor.valu
document.form1.aColor.valu
}
</SCRIPT>
Text Box
<input type="text" name="oColor" value="">
Search Button
<INPUT TYPE="button" VALUE="Search" onclick="callDialog()">
testcallee.asp
HTML>
<HEAD>
<TITLE>callee.html</TITLE>
<SCRIPT>
function getInfoAndUpdate() {
var callerWindowObj = dialogArguments;
callerWindowObj.sColor = oEnterColor.value;
callerWindowObj.update();
}
function cancel() {
var callerWindowObj = dialogArguments;
callerWindowObj.sColor = "Yellow";
callerWindowObj.update();
}
</SCRIPT>
</HEAD>
<BODY>
Enter your favorite color:<INPUT ID=oEnterColor><BR><BR>
<INPUT VALUE="Apply" TYPE=button onclick="getInfoAndUpdate(
<INPUT VALUE="Ok" TYPE=button onclick="getInfoAndUpdate(
<INPUT VALUE="Cancel" TYPE=button onclick="cancel();window.c
</BODY>
</HTML>
Now i would like to be able to return the value into a drop down list......
which i build from a database
<%Call CreateOption("AssetTag","s
<%sub CreateOption(strName,strTa
'This subroutine expects the following parameters:
' strName is the name of option to be created
' strTableNameOrSQL the name of table
' strValue is the field from the recordset that holds the value to be stored;
'strDisplay is the field from the recordset that will be displayed in the drop down;
'if a default value is to be selected, that is passed as strSelected. strJavaScript holds
'any event and script to be fired with that event.
dim objRSOption, strIsSelected
set objRSOption=Server.CreateO
objRSOption.Open strTableOrSQL,dbConn
response.write("<Select Name = '" & strName & "'" & strJavaScript & ">")
response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & vbTab & "<Option Value = ''></Option>")
Do until objRSOption.eof
if Trim(UCase(objRSOption(str
strIsSelected = " selected"
else
strIsSelected = ""
end if
Response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & vbTab & "<Option" & strIsSelected & " Value ='" & objRSOption(strValue) & "'>" & objRSOption(strDisplay) & "</Option>")
objRSOption.MoveNext
Loop
Response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & "</Select>")
objRSOption.close
set objRSOption = Nothing
end sub%>
Possible.............to set the selected dropdown to the oColor coming in from the javascript
1) the asp subroutine function creates the select list
2) the popup appears
3) a value is returned
As you can see, 3 takes place well after 1 does.
2) the popup appears
3) a value is returned
As you can see, 3 takes place well after 1 does.
Having said that, if you return a value from the pop up, it may be possible to reset the value of the select list using client side code.
FtB
FtB
Did you try to add the information to the array??
ASKER
Arrays are a little more complex for me...............this javascript is bad enough...
I hear you fritz..
is there a way with the client.......when it comes to do it....
I hear you fritz..
is there a way with the client.......when it comes to do it....
Okay, so how do you get the value back from your popup? To what variable is it stored? Also, do you get the text or the value back, i.e., how does this relate to the select list that you want to manipulate?
FtB
FtB
TRACEMARY,
You won't be able to do it with JAVASCRIPT. Here is the deal, I have done it through JSP. I can give you idea how to do it, and may be you can try doing it with ASP.
to get information on JSP follow the link..
https://www.experts-exchange.com/questions/21119382/Adding-table-on-a-jsp-URGENT.html
Remember same loginc will be used to update list dynamically..
-Raj
You won't be able to do it with JAVASCRIPT. Here is the deal, I have done it through JSP. I can give you idea how to do it, and may be you can try doing it with ASP.
to get information on JSP follow the link..
https://www.experts-exchange.com/questions/21119382/Adding-table-on-a-jsp-URGENT.html
Remember same loginc will be used to update list dynamically..
-Raj
>>You won't be able to do it with JAVASCRIPT.<<
Are you sure? If you can pass a value back to the page, then we could do something like:
document.forms[0].elements ['AssetTag '].selecte dIndex = intIndexToSelect;
Or if we have to, we can iterate through the select list with client-side code until we find the match and then set the selected index then.
FtB
Are you sure? If you can pass a value back to the page, then we could do something like:
document.forms[0].elements
Or if we have to, we can iterate through the select list with client-side code until we find the match and then set the selected index then.
FtB
We did that in TRACEYMARY's last question
https://www.experts-exchange.com/questions/21157994/Pass-information-from-one-page-to-another.html
Problem is How do we update list dynamically? We can save value from other page in array that's not a problem. But display array values ???
Let me know if need help in adding the values to array, and may be "FtB" cam figure out something to display array to the option list..
-Raj
https://www.experts-exchange.com/questions/21157994/Pass-information-from-one-page-to-another.html
Problem is How do we update list dynamically? We can save value from other page in array that's not a problem. But display array values ???
Let me know if need help in adding the values to array, and may be "FtB" cam figure out something to display array to the option list..
-Raj
ASKER
Ok....this is getting hard but now im geared to getting it to work.
First Page a1.asp
<form name="form1" method="GET" action="assetticket_view.a sp">
<table width="100%" border="0">
<tr>
<td width="29%"><span class="style3">Asset Tag </span></td>
<td width="71%">
<p>
<input name=t>
<input type=button value=choose onclick=window.open("asset search.asp ")>
assetsearch.asp
I added
<a href='javascript:window.op ener.docum ent.form1. t.value=3; self.close ()'>return 3></a>
and it returns 3 to the page ......in my correct textbox....called t...great..
Now if i do it to return a recordset value
td>
<%response.write rs("ASSETTAG") %>
<a href='javascript:window.op ener.docum ent.form1. t.value=<% =rs("ASSET TAG")%>;se lf.close() '>return 3></a>
</td>
I do not get my recordset value...(I see in the browser window it selecting value but on return i get
16384 instead of my recordset value 040000
and 16413 instead of value 040035
That is odd..............(any reason for this)...
Once working i can get on to the Select....part
Cheers
First Page a1.asp
<form name="form1" method="GET" action="assetticket_view.a
<table width="100%" border="0">
<tr>
<td width="29%"><span class="style3">Asset Tag </span></td>
<td width="71%">
<p>
<input name=t>
<input type=button value=choose onclick=window.open("asset
assetsearch.asp
I added
<a href='javascript:window.op
and it returns 3 to the page ......in my correct textbox....called t...great..
Now if i do it to return a recordset value
td>
<%response.write rs("ASSETTAG") %>
<a href='javascript:window.op
</td>
I do not get my recordset value...(I see in the browser window it selecting value but on return i get
16384 instead of my recordset value 040000
and 16413 instead of value 040035
That is odd..............(any reason for this)...
Once working i can get on to the Select....part
Cheers
So, is the idea here not to select an item, but rather, to add an item to the list? If so, we can append a pair to the select list using client-side scripting.
FtB
FtB
ASKER
Well the idea is
... the user can select from the drop down list
....or if want to get more information as do not know the number then go and use search
then when that values returns
put it in the position where the drop down list is..as a selected value.
just as if they had used the drop down feature....
(so that my program only looks at one place for the value and that be in the select list.)
... the user can select from the drop down list
....or if want to get more information as do not know the number then go and use search
then when that values returns
put it in the position where the drop down list is..as a selected value.
just as if they had used the drop down feature....
(so that my program only looks at one place for the value and that be in the select list.)
Okay, that should be fine then. Once you get the value from the window, we can use it to set the selected property of the select list. Will you be passing the value or the text for the select list from the popup to the page?
FtB
FtB
I might have a good news soon...
I got item inserted to the list now only problem is to get it selected...
I got item inserted to the list now only problem is to get it selected...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oops, that should be:
objSel = document.forms[0].elements ['AssetTag ']
intLength = objSel.length;
objSel.options[intLength]= new Option;
objSel.options[intLength]. value = strValue;
objSel.options[intLength]. text = strText;
objSel.selectedIndex = intLength
objSel = document.forms[0].elements
intLength = objSel.length;
objSel.options[intLength]=
objSel.options[intLength].
objSel.options[intLength].
objSel.selectedIndex = intLength
Perfect
here is the working code
caller.html
++++++++++++++++++++++++++ +
<HEAD>
<TITLE>DialogArguments Example</TITLE>
<SCRIPT>
var sColor="";
function callDialog() {
showModelessDialog("callee .html",win dow,"statu s:false;di alogWidth: 300px;dial ogHeight:1 50px");
}
function update() {
fbox=sColor;
tbox = document.form1.list1;
<!-- Begin
sortitems = 1; // Automatically sort items within lists? (1 or 0)
var no = new Option();
no.value = fbox;
no.text = fbox;
tbox.options[tbox.options. length] = no;
tbox.selectedIndex = no;
fbox= "";
if (sortitems) SortD(tbox);
}
function SortD(box) {
var temp_opts = new Array();
var temp = new Object();
for(var i=0; i<box.options.length; i++) {
temp_opts[i] = box.options[i];
}
for(var x=0; x<temp_opts.length-1; x++) {
for(var y=(x+1); y<temp_opts.length; y++) {
if(temp_opts[x].text > temp_opts[y].text) {
temp = temp_opts[x].text;
temp_opts[x].text = temp_opts[y].text;
temp_opts[y].text = temp;
}
}
}
for(var i=0; i<box.options.length; i++) {
box.options[i].value = temp_opts[i].value;
box.options[i].text = temp_opts[i].text;
}
}
// End -->
</script>
</HEAD>
<BODY>
<form name="form1">
<input name="txtAssetTag" type="text" id="txtAssetTag">
<select multiple size="5" name="list1">
<option value="11"> item 1.1 </option>
<option value="12"> item 1.2 </option>
<option value="13"> item 1.3 </option>
</select>
<INPUT TYPE="button" VALUE="Add Item" onclick="callDialog()">
</form>
</BODY>
</HTML>
++++++++++++++++++++++++++ ++++
callee.html
========================== =
<HTML>
<HEAD>
<TITLE>callee.html</TITLE>
<SCRIPT>
function getInfoAndUpdate() {
var callerWindowObj = dialogArguments;
callerWindowObj.sColor = oEnterColor.value;
callerWindowObj.update();
}
function cancel() {
var callerWindowObj = dialogArguments;
callerWindowObj.sColor = "No Item";
callerWindowObj.update();
}
</SCRIPT>
</HEAD>
<BODY>
Enter your item:<INPUT ID=oEnterColor><BR><BR>
<INPUT VALUE="Ok" TYPE=button onclick="getInfoAndUpdate( );window.c lose();">
<INPUT VALUE="Cancel" TYPE=button onclick="cancel();window.c lose();">
</BODY>
</HTML>
========================
-Raj
here is the working code
caller.html
++++++++++++++++++++++++++
<HEAD>
<TITLE>DialogArguments Example</TITLE>
<SCRIPT>
var sColor="";
function callDialog() {
showModelessDialog("callee
}
function update() {
fbox=sColor;
tbox = document.form1.list1;
<!-- Begin
sortitems = 1; // Automatically sort items within lists? (1 or 0)
var no = new Option();
no.value = fbox;
no.text = fbox;
tbox.options[tbox.options.
tbox.selectedIndex = no;
fbox= "";
if (sortitems) SortD(tbox);
}
function SortD(box) {
var temp_opts = new Array();
var temp = new Object();
for(var i=0; i<box.options.length; i++) {
temp_opts[i] = box.options[i];
}
for(var x=0; x<temp_opts.length-1; x++) {
for(var y=(x+1); y<temp_opts.length; y++) {
if(temp_opts[x].text > temp_opts[y].text) {
temp = temp_opts[x].text;
temp_opts[x].text = temp_opts[y].text;
temp_opts[y].text = temp;
}
}
}
for(var i=0; i<box.options.length; i++) {
box.options[i].value = temp_opts[i].value;
box.options[i].text = temp_opts[i].text;
}
}
// End -->
</script>
</HEAD>
<BODY>
<form name="form1">
<input name="txtAssetTag" type="text" id="txtAssetTag">
<select multiple size="5" name="list1">
<option value="11"> item 1.1 </option>
<option value="12"> item 1.2 </option>
<option value="13"> item 1.3 </option>
</select>
<INPUT TYPE="button" VALUE="Add Item" onclick="callDialog()">
</form>
</BODY>
</HTML>
++++++++++++++++++++++++++
callee.html
==========================
<HTML>
<HEAD>
<TITLE>callee.html</TITLE>
<SCRIPT>
function getInfoAndUpdate() {
var callerWindowObj = dialogArguments;
callerWindowObj.sColor = oEnterColor.value;
callerWindowObj.update();
}
function cancel() {
var callerWindowObj = dialogArguments;
callerWindowObj.sColor = "No Item";
callerWindowObj.update();
}
</SCRIPT>
</HEAD>
<BODY>
Enter your item:<INPUT ID=oEnterColor><BR><BR>
<INPUT VALUE="Ok" TYPE=button onclick="getInfoAndUpdate(
<INPUT VALUE="Cancel" TYPE=button onclick="cancel();window.c
</BODY>
</HTML>
========================
-Raj
ASKER
Ok i made a simple program.
a1.htm
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!-- #INCLUDE FILE="adovbs.Inc" -->
<html>
<head>
<title>Tickets</title>
<link href="CSS/Accessible_Desig n_Assets.c ss" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style3 {color: #336699; font-weight: bold; }
-->
</style>
</head>
<body>
<form name="form1" method="GET" action="a1.htm">
<table width="100%" border="0">
<tr>
<td width="29%"><span class="style3">Employee </span></td>
<td width="71%">
<p>
<input name=t>
<input type=button value=choose onclick=window.open("asset search.asp ")>
</p></td>
</form>
</body>
</html>
calls
assetsearch.asp
using northwind database here of employees
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!-- #INCLUDE FILE="adovbs.Inc" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Tickets</title>
<link href="CSS/Accessible_Desig n_Assets.c ss" rel="stylesheet" type="text/css">
<%
dim dbConn
set dbConn = server.createobject("adodb .Connectio n")
dbConn.open Session("DATABASENORTHWIND ")
Set rs = Server.CreateObject("ADODB .Recordset ")
%>
<style type="text/css">
<!--
.style3 {color: #336699; font-weight: bold; }
-->
</style>
</head>
<body>
<p align="center"> </p>
<p align="center"><strong>
<%
strSQL = "select * from Employees"
rs.CursorLocation = 3
rs.Open strSQL, dbConn, 3
rs.PageSize = 15 'Records per page
If Request.Querystring("page" ) = "" Then
myPage = 1
Else
myPage = Request.Querystring("page" )
End If
iPages = rs.PageCount
if iPages > 0 then
rs.AbsolutePage = myPage
else
response.write "No Employees"
response.end
end if
Count = 0
%>
<table border="1">
<tr bgcolor="#336699"><td><spa n class="BulletBackgroundCol or">Employ ee</span>< /td>
</tr>
<tr>
<%Do While Count < rs.PageSize And Not rs.EOF%>
<tr><td><%response.write rs("FirstName") %>
<%myvalue = rs("FirstName")%>
<a href='javascript:window.op ener.docum ent.form1. t.value=3; self.close ()'>return 3></a>
</td>
<%Count = Count + 1
rs.MoveNext
Loop
%>
</table>
<%
If CInt(myPage) > 1 Then
%>
<a href="assetsearch.asp.asp? page=<%= myPage -1 %>">Prev</a>
<%
End If
If rs.PageCount > 1 Then
For i = 1 To rs.PageCount
%>
<a href="assetsearch.asp?page =<%= i %>"><%= i %></a>
<%
Next
End If
If CInt(myPage) < CInt(iPages) Then
%>
<a href="assetsearch.asp?page =<%= myPage +1 %>">Next</a>
<%
End If
%>
</body>
</html>
This returns the 3 but when i do
<a href='javascript:window.op ener.docum ent.form1. t.value=3; self.close ()'>return 3></a>
<a href='javascript:window.op ener.docum ent.form1. t.value=<% =rs("First Name")%>;s elf.close( )'>return 3></a>
I get javascript error.
Need to get this bit working then go to the complex select part.
Phew................
a1.htm
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!-- #INCLUDE FILE="adovbs.Inc" -->
<html>
<head>
<title>Tickets</title>
<link href="CSS/Accessible_Desig
<style type="text/css">
<!--
.style3 {color: #336699; font-weight: bold; }
-->
</style>
</head>
<body>
<form name="form1" method="GET" action="a1.htm">
<table width="100%" border="0">
<tr>
<td width="29%"><span class="style3">Employee </span></td>
<td width="71%">
<p>
<input name=t>
<input type=button value=choose onclick=window.open("asset
</p></td>
</form>
</body>
</html>
calls
assetsearch.asp
using northwind database here of employees
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!-- #INCLUDE FILE="adovbs.Inc" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Tickets</title>
<link href="CSS/Accessible_Desig
<%
dim dbConn
set dbConn = server.createobject("adodb
dbConn.open Session("DATABASENORTHWIND
Set rs = Server.CreateObject("ADODB
%>
<style type="text/css">
<!--
.style3 {color: #336699; font-weight: bold; }
-->
</style>
</head>
<body>
<p align="center"> </p>
<p align="center"><strong>
<%
strSQL = "select * from Employees"
rs.CursorLocation = 3
rs.Open strSQL, dbConn, 3
rs.PageSize = 15 'Records per page
If Request.Querystring("page"
myPage = 1
Else
myPage = Request.Querystring("page"
End If
iPages = rs.PageCount
if iPages > 0 then
rs.AbsolutePage = myPage
else
response.write "No Employees"
response.end
end if
Count = 0
%>
<table border="1">
<tr bgcolor="#336699"><td><spa
</tr>
<tr>
<%Do While Count < rs.PageSize And Not rs.EOF%>
<tr><td><%response.write rs("FirstName") %>
<%myvalue = rs("FirstName")%>
<a href='javascript:window.op
</td>
<%Count = Count + 1
rs.MoveNext
Loop
%>
</table>
<%
If CInt(myPage) > 1 Then
%>
<a href="assetsearch.asp.asp?
<%
End If
If rs.PageCount > 1 Then
For i = 1 To rs.PageCount
%>
<a href="assetsearch.asp?page
<%
Next
End If
If CInt(myPage) < CInt(iPages) Then
%>
<a href="assetsearch.asp?page
<%
End If
%>
</body>
</html>
This returns the 3 but when i do
<a href='javascript:window.op
<a href='javascript:window.op
I get javascript error.
Need to get this bit working then go to the complex select part.
Phew................
TRACEYMARY, Is that what you are looking for....
ASKER
ok just got it working with the recordset listing the values.
<HEAD>
<TITLE>DialogArguments Example</TITLE>
<SCRIPT>
var sColor="";
function callDialog() {
showModelessDialog("callee _a.asp",wi ndow,"stat us:false;d ialogWidth :300px;dia logHeight: 150px");
}
function update() {
fbox=sColor;
tbox = document.form1.list1;
<!-- Begin
sortitems = 1; // Automatically sort items within lists? (1 or 0)
var no = new Option();
no.value = fbox;
no.text = fbox;
tbox.options[tbox.options. length] = no;
tbox.selectedIndex = no;
fbox= "";
if (sortitems) SortD(tbox);
}
function SortD(box) {
var temp_opts = new Array();
var temp = new Object();
for(var i=0; i<box.options.length; i++) {
temp_opts[i] = box.options[i];
}
for(var x=0; x<temp_opts.length-1; x++) {
for(var y=(x+1); y<temp_opts.length; y++) {
if(temp_opts[x].text > temp_opts[y].text) {
temp = temp_opts[x].text;
temp_opts[x].text = temp_opts[y].text;
temp_opts[y].text = temp;
}
}
}
for(var i=0; i<box.options.length; i++) {
box.options[i].value = temp_opts[i].value;
box.options[i].text = temp_opts[i].text;
}
}
// End -->
</script>
<%
dim dbConn
set dbConn = server.createobject("adodb .Connectio n")
dbConn.open Session("DATABASENORTHWIND ")
Set rs = Server.CreateObject("ADODB .Recordset ")
%>
</HEAD>
<BODY>
<form name="form1">
<input name="txtAssetTag" type="text" id="txtAssetTag">
<%Call CreateOption("list1","sele ct distinct FIRSTNAME from EMPLOYEES ","FIRSTNAME","FIRSTNAME", request("FIRSTNAME"))%>
<INPUT TYPE="button" VALUE="Add Item" onclick="callDialog()">
</form>
<%sub CreateOption(strName,strTa bleOrSQL,s trValue,st rDisplay, strSelected)
'This subroutine expects the following parameters:
' strName is the name of option to be created
' strTableNameOrSQL the name of table
' strValue is the field from the recordset that holds the value to be stored;
'strDisplay is the field from the recordset that will be displayed in the drop down;
'if a default value is to be selected, that is passed as strSelected. strJavaScript holds
'any event and script to be fired with that event.
dim objRSOption, strIsSelected
set objRSOption=Server.CreateO bject("ADO DB.RecordS et")
objRSOption.Open strTableOrSQL,dbConn
response.write("<Select Name = '" & strName & "'" & strJavaScript & ">")
response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & vbTab & "<Option Value = ''></Option>")
Do until objRSOption.eof
if Trim(UCase(objRSOption(str Value))) = Trim(UCase(strSelected)) then
strIsSelected = " selected"
else
strIsSelected = ""
end if
Response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & vbTab & "<Option" & strIsSelected & " Value ='" & objRSOption(strValue) & "'>" & objRSOption(strDisplay) & "</Option>")
objRSOption.MoveNext
Loop
Response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & "</Select>")
objRSOption.close
set objRSOption = Nothing
end sub%>
</BODY>
</HTML>
Now...it returns to the drop down great..................... .(is there a way to make that the first visible..)...
that be great...
Then the calling program................... ..(i need to pass from another paging list of records)..
but so far that pretty dam good programming...
<HEAD>
<TITLE>DialogArguments Example</TITLE>
<SCRIPT>
var sColor="";
function callDialog() {
showModelessDialog("callee
}
function update() {
fbox=sColor;
tbox = document.form1.list1;
<!-- Begin
sortitems = 1; // Automatically sort items within lists? (1 or 0)
var no = new Option();
no.value = fbox;
no.text = fbox;
tbox.options[tbox.options.
tbox.selectedIndex = no;
fbox= "";
if (sortitems) SortD(tbox);
}
function SortD(box) {
var temp_opts = new Array();
var temp = new Object();
for(var i=0; i<box.options.length; i++) {
temp_opts[i] = box.options[i];
}
for(var x=0; x<temp_opts.length-1; x++) {
for(var y=(x+1); y<temp_opts.length; y++) {
if(temp_opts[x].text > temp_opts[y].text) {
temp = temp_opts[x].text;
temp_opts[x].text = temp_opts[y].text;
temp_opts[y].text = temp;
}
}
}
for(var i=0; i<box.options.length; i++) {
box.options[i].value = temp_opts[i].value;
box.options[i].text = temp_opts[i].text;
}
}
// End -->
</script>
<%
dim dbConn
set dbConn = server.createobject("adodb
dbConn.open Session("DATABASENORTHWIND
Set rs = Server.CreateObject("ADODB
%>
</HEAD>
<BODY>
<form name="form1">
<input name="txtAssetTag" type="text" id="txtAssetTag">
<%Call CreateOption("list1","sele
<INPUT TYPE="button" VALUE="Add Item" onclick="callDialog()">
</form>
<%sub CreateOption(strName,strTa
'This subroutine expects the following parameters:
' strName is the name of option to be created
' strTableNameOrSQL the name of table
' strValue is the field from the recordset that holds the value to be stored;
'strDisplay is the field from the recordset that will be displayed in the drop down;
'if a default value is to be selected, that is passed as strSelected. strJavaScript holds
'any event and script to be fired with that event.
dim objRSOption, strIsSelected
set objRSOption=Server.CreateO
objRSOption.Open strTableOrSQL,dbConn
response.write("<Select Name = '" & strName & "'" & strJavaScript & ">")
response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & vbTab & "<Option Value = ''></Option>")
Do until objRSOption.eof
if Trim(UCase(objRSOption(str
strIsSelected = " selected"
else
strIsSelected = ""
end if
Response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & vbTab & "<Option" & strIsSelected & " Value ='" & objRSOption(strValue) & "'>" & objRSOption(strDisplay) & "</Option>")
objRSOption.MoveNext
Loop
Response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & "</Select>")
objRSOption.close
set objRSOption = Nothing
end sub%>
</BODY>
</HTML>
Now...it returns to the drop down great.....................
that be great...
Then the calling program...................
but so far that pretty dam good programming...
ASKER
Ok got both programs here:
<HEAD>
<TITLE>DialogArguments Example</TITLE>
<SCRIPT>
var sColor="";
function callDialog() {
showModelessDialog("callee _a.asp",wi ndow,"stat us:false;d ialogWidth :300px;dia logHeight: 150px");
}
function update() {
fbox=sColor;
tbox = document.form1.list1;
<!-- Begin
sortitems = 1; // Automatically sort items within lists? (1 or 0)
var no = new Option();
no.value = fbox;
no.text = fbox;
tbox.options[tbox.options. length] = no;
tbox.selectedIndex = no;
fbox= "";
if (sortitems) SortD(tbox);
}
function SortD(box) {
var temp_opts = new Array();
var temp = new Object();
for(var i=0; i<box.options.length; i++) {
temp_opts[i] = box.options[i];
}
for(var x=0; x<temp_opts.length-1; x++) {
for(var y=(x+1); y<temp_opts.length; y++) {
if(temp_opts[x].text > temp_opts[y].text) {
temp = temp_opts[x].text;
temp_opts[x].text = temp_opts[y].text;
temp_opts[y].text = temp;
}
}
}
for(var i=0; i<box.options.length; i++) {
box.options[i].value = temp_opts[i].value;
box.options[i].text = temp_opts[i].text;
}
}
// End -->
</script>
<%
dim dbConn
set dbConn = server.createobject("adodb .Connectio n")
dbConn.open Session("DATABASENORTHWIND ")
Set rs = Server.CreateObject("ADODB .Recordset ")
%>
</HEAD>
<BODY>
<form name="form1">
<input name="txtAssetTag" type="text" id="txtAssetTag">
<%Call CreateOption("list1","sele ct distinct FIRSTNAME from EMPLOYEES ","FIRSTNAME","FIRSTNAME", request("FIRSTNAME"))%>
<INPUT TYPE="button" VALUE="Add Item" onclick="callDialog()">
</form>
<%sub CreateOption(strName,strTa bleOrSQL,s trValue,st rDisplay, strSelected)
'This subroutine expects the following parameters:
' strName is the name of option to be created
' strTableNameOrSQL the name of table
' strValue is the field from the recordset that holds the value to be stored;
'strDisplay is the field from the recordset that will be displayed in the drop down;
'if a default value is to be selected, that is passed as strSelected. strJavaScript holds
'any event and script to be fired with that event.
dim objRSOption, strIsSelected
set objRSOption=Server.CreateO bject("ADO DB.RecordS et")
objRSOption.Open strTableOrSQL,dbConn
response.write("<Select Name = '" & strName & "'" & strJavaScript & ">")
response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & vbTab & "<Option Value = ''></Option>")
Do until objRSOption.eof
if Trim(UCase(objRSOption(str Value))) = Trim(UCase(strSelected)) then
strIsSelected = " selected"
else
strIsSelected = ""
end if
Response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & vbTab & "<Option" & strIsSelected & " Value ='" & objRSOption(strValue) & "'>" & objRSOption(strDisplay) & "</Option>")
objRSOption.MoveNext
Loop
Response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & "</Select>")
objRSOption.close
set objRSOption = Nothing
end sub%>
</BODY>
</HTML>
--------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<HTML>
<HEAD>
<TITLE>callee.html</TITLE>
<SCRIPT>
function getInfoAndUpdate() {
var callerWindowObj = dialogArguments;
callerWindowObj.sColor = oEnterColor.value;
callerWindowObj.update();
}
function cancel() {
var callerWindowObj = dialogArguments;
callerWindowObj.sColor = "No Item";
callerWindowObj.update();
}
</SCRIPT>
</HEAD>
<BODY>
Enter your item:<INPUT ID=oEnterColor><BR><BR>
<INPUT VALUE="Ok" TYPE=button onclick="getInfoAndUpdate( );window.c lose();">
<INPUT VALUE="Cancel" TYPE=button onclick="cancel();window.c lose();">
<%
dim dbConn
set dbConn = server.createobject("adodb .Connectio n")
dbConn.open Session("DATABASENORTHWIND ")
Set rs = Server.CreateObject("ADODB .Recordset ")
%>
<style type="text/css">
<!--
.style3 {color: #336699; font-weight: bold; }
-->
</style>
</head>
<body>
<p align="center"> </p>
<p align="center"><strong>
<%
strSQL = "select * from Employees"
rs.CursorLocation = 3
rs.Open strSQL, dbConn, 3
rs.PageSize = 15 'Records per page
If Request.Querystring("page" ) = "" Then
myPage = 1
Else
myPage = Request.Querystring("page" )
End If
iPages = rs.PageCount
if iPages > 0 then
rs.AbsolutePage = myPage
else
response.write "No Employees"
response.end
end if
Count = 0
%>
<table border="1">
<tr bgcolor="#336699"><td><spa n class="BulletBackgroundCol or">Employ ee</span>< /td>
</tr>
<tr>
<%Do While Count < rs.PageSize And Not rs.EOF%>
<tr><td><%response.write rs("FirstName") %>
<%myvalue = rs("FirstName")%>
<a href='javascript:window.op ener.docum ent.form1. t.value=<% =rs("First Name")%>;s elf.close( )'>return 3></a>
</td>
<%Count = Count + 1
rs.MoveNext
Loop
%>
</table>
<%
If CInt(myPage) > 1 Then
%>
<a href="assetsearch.asp.asp? page=<%= myPage -1 %>">Prev</a>
<%
End If
If rs.PageCount > 1 Then
For i = 1 To rs.PageCount
%>
<a href="assetsearch.asp?page =<%= i %>"><%= i %></a>
<%
Next
End If
If CInt(myPage) < CInt(iPages) Then
%>
<a href="assetsearch.asp?page =<%= myPage +1 %>">Next</a>
<%
End If
%>
</body>
</HTML>
If i do the add ...name in the enter box it works great.........
I like to be able to select from the pull down list of records in the child page and that value to return into the select box.
and be the first one..
Wow looking like there is light at the end of a tunnel.
<HEAD>
<TITLE>DialogArguments Example</TITLE>
<SCRIPT>
var sColor="";
function callDialog() {
showModelessDialog("callee
}
function update() {
fbox=sColor;
tbox = document.form1.list1;
<!-- Begin
sortitems = 1; // Automatically sort items within lists? (1 or 0)
var no = new Option();
no.value = fbox;
no.text = fbox;
tbox.options[tbox.options.
tbox.selectedIndex = no;
fbox= "";
if (sortitems) SortD(tbox);
}
function SortD(box) {
var temp_opts = new Array();
var temp = new Object();
for(var i=0; i<box.options.length; i++) {
temp_opts[i] = box.options[i];
}
for(var x=0; x<temp_opts.length-1; x++) {
for(var y=(x+1); y<temp_opts.length; y++) {
if(temp_opts[x].text > temp_opts[y].text) {
temp = temp_opts[x].text;
temp_opts[x].text = temp_opts[y].text;
temp_opts[y].text = temp;
}
}
}
for(var i=0; i<box.options.length; i++) {
box.options[i].value = temp_opts[i].value;
box.options[i].text = temp_opts[i].text;
}
}
// End -->
</script>
<%
dim dbConn
set dbConn = server.createobject("adodb
dbConn.open Session("DATABASENORTHWIND
Set rs = Server.CreateObject("ADODB
%>
</HEAD>
<BODY>
<form name="form1">
<input name="txtAssetTag" type="text" id="txtAssetTag">
<%Call CreateOption("list1","sele
<INPUT TYPE="button" VALUE="Add Item" onclick="callDialog()">
</form>
<%sub CreateOption(strName,strTa
'This subroutine expects the following parameters:
' strName is the name of option to be created
' strTableNameOrSQL the name of table
' strValue is the field from the recordset that holds the value to be stored;
'strDisplay is the field from the recordset that will be displayed in the drop down;
'if a default value is to be selected, that is passed as strSelected. strJavaScript holds
'any event and script to be fired with that event.
dim objRSOption, strIsSelected
set objRSOption=Server.CreateO
objRSOption.Open strTableOrSQL,dbConn
response.write("<Select Name = '" & strName & "'" & strJavaScript & ">")
response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & vbTab & "<Option Value = ''></Option>")
Do until objRSOption.eof
if Trim(UCase(objRSOption(str
strIsSelected = " selected"
else
strIsSelected = ""
end if
Response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & vbTab & "<Option" & strIsSelected & " Value ='" & objRSOption(strValue) & "'>" & objRSOption(strDisplay) & "</Option>")
objRSOption.MoveNext
Loop
Response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & "</Select>")
objRSOption.close
set objRSOption = Nothing
end sub%>
</BODY>
</HTML>
--------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<HTML>
<HEAD>
<TITLE>callee.html</TITLE>
<SCRIPT>
function getInfoAndUpdate() {
var callerWindowObj = dialogArguments;
callerWindowObj.sColor = oEnterColor.value;
callerWindowObj.update();
}
function cancel() {
var callerWindowObj = dialogArguments;
callerWindowObj.sColor = "No Item";
callerWindowObj.update();
}
</SCRIPT>
</HEAD>
<BODY>
Enter your item:<INPUT ID=oEnterColor><BR><BR>
<INPUT VALUE="Ok" TYPE=button onclick="getInfoAndUpdate(
<INPUT VALUE="Cancel" TYPE=button onclick="cancel();window.c
<%
dim dbConn
set dbConn = server.createobject("adodb
dbConn.open Session("DATABASENORTHWIND
Set rs = Server.CreateObject("ADODB
%>
<style type="text/css">
<!--
.style3 {color: #336699; font-weight: bold; }
-->
</style>
</head>
<body>
<p align="center"> </p>
<p align="center"><strong>
<%
strSQL = "select * from Employees"
rs.CursorLocation = 3
rs.Open strSQL, dbConn, 3
rs.PageSize = 15 'Records per page
If Request.Querystring("page"
myPage = 1
Else
myPage = Request.Querystring("page"
End If
iPages = rs.PageCount
if iPages > 0 then
rs.AbsolutePage = myPage
else
response.write "No Employees"
response.end
end if
Count = 0
%>
<table border="1">
<tr bgcolor="#336699"><td><spa
</tr>
<tr>
<%Do While Count < rs.PageSize And Not rs.EOF%>
<tr><td><%response.write rs("FirstName") %>
<%myvalue = rs("FirstName")%>
<a href='javascript:window.op
</td>
<%Count = Count + 1
rs.MoveNext
Loop
%>
</table>
<%
If CInt(myPage) > 1 Then
%>
<a href="assetsearch.asp.asp?
<%
End If
If rs.PageCount > 1 Then
For i = 1 To rs.PageCount
%>
<a href="assetsearch.asp?page
<%
Next
End If
If CInt(myPage) < CInt(iPages) Then
%>
<a href="assetsearch.asp?page
<%
End If
%>
</body>
</HTML>
If i do the add ...name in the enter box it works great.........
I like to be able to select from the pull down list of records in the child page and that value to return into the select box.
and be the first one..
Wow looking like there is light at the end of a tunnel.
Didn't get you, go again... in simple words...
thanks... and thanks to FtB
thanks... and thanks to FtB
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Smiles ok...getting carried away with myself over here
2nd Page.
I display a list of records from database
so rather than type in the text box...enter your ..
you select the record in the paging section
So im trying to make the following be the value which is from database list rather than the text box field value
<input ID=oEnterColor value="<%=rs("FirstName")% >">
<INPUT VALUE="Ok" TYPE=button onclick="getInfoAndUpdate( );window.c lose();">
instead of
Enter your item:<INPUT ID=oEnterColor><BR><BR>
<INPUT VALUE="Ok" TYPE=button onclick="getInfoAndUpdate( );window.c lose();">
<INPUT VALUE="Cancel" TYPE=button onclick="cancel();window.c lose();">
It works but it returns value undefined......
Cheers
2nd Page.
I display a list of records from database
so rather than type in the text box...enter your ..
you select the record in the paging section
So im trying to make the following be the value which is from database list rather than the text box field value
<input ID=oEnterColor value="<%=rs("FirstName")%
<INPUT VALUE="Ok" TYPE=button onclick="getInfoAndUpdate(
instead of
Enter your item:<INPUT ID=oEnterColor><BR><BR>
<INPUT VALUE="Ok" TYPE=button onclick="getInfoAndUpdate(
<INPUT VALUE="Cancel" TYPE=button onclick="cancel();window.c
It works but it returns value undefined......
Cheers
but I guess this way you will be getting only on value, you said you want to select from the list, something like this:
<HTML>
<HEAD>
<TITLE>callee.html</TITLE>
<SCRIPT>
function getInfoAndUpdate() {
var callerWindowObj = dialogArguments;
callerWindowObj.sValue = oEnterColor.value;
callerWindowObj.sText = oEnterColor.text;
callerWindowObj.update();
}
function cancel() {
var callerWindowObj = dialogArguments;
callerWindowObj.sValue = "";
callerWindowObj.sText = "";
callerWindowObj.update();
}
</SCRIPT>
</HEAD>
<BODY>
<select name="oEnterColor">
<option value="1">One // these options will be coming from database....
<option value="2">Two
<option value="3">Three
</select>
<INPUT VALUE="Ok" TYPE=button onclick="getInfoAndUpdate( );window.c lose();">
<INPUT VALUE="Cancel" TYPE=button onclick="cancel();window.c lose();">
</BODY>
</HTML>
===============
I am getting undefined too... but it will work, keep trying.. I will be back soon...
Bye
<HTML>
<HEAD>
<TITLE>callee.html</TITLE>
<SCRIPT>
function getInfoAndUpdate() {
var callerWindowObj = dialogArguments;
callerWindowObj.sValue = oEnterColor.value;
callerWindowObj.sText = oEnterColor.text;
callerWindowObj.update();
}
function cancel() {
var callerWindowObj = dialogArguments;
callerWindowObj.sValue = "";
callerWindowObj.sText = "";
callerWindowObj.update();
}
</SCRIPT>
</HEAD>
<BODY>
<select name="oEnterColor">
<option value="1">One // these options will be coming from database....
<option value="2">Two
<option value="3">Three
</select>
<INPUT VALUE="Ok" TYPE=button onclick="getInfoAndUpdate(
<INPUT VALUE="Cancel" TYPE=button onclick="cancel();window.c
</BODY>
</HTML>
===============
I am getting undefined too... but it will work, keep trying.. I will be back soon...
Bye
ASKER
Not a problem thanks
Do you have a link that I can look at?
FtB
FtB
ASKER
Ok i managed to get it to work using the
<a href="javascript:window.op ener.docum ent.form1. category.v alue='<%=r s("CATEGOR Y_ID")%>'; self.close ();"><%=rs ("CATEGORY _ID")%></a >
and returning to this
<input name=category>
<input type=button value=choose onclick=window.open("call_ search.asp ")>
The other javascript part is really good raj......but i think i have to get up to speed on javascript really quickly.
So i use the this example as it works....................a nd is easy to amend if i get any errors.
As to populate the list drop down ..........(thats a luxury).
So i keep working on the other part...................... .but for now got a work around.
Thanks ........i close out the bug....
If i get a work around for this: using modal
<HEAD>
<TITLE>DialogArguments Example</TITLE>
<SCRIPT>
var sColor="";
function callDialog() {
showModelessDialog("callee _a.asp",wi ndow,"stat us:false;d ialogWidth :300px;dia logHeight: 150px");
}
function update() {
fbox=sColor;
tbox = document.form1.list1;
<!-- Begin
sortitems = 1; // Automatically sort items within lists? (1 or 0)
var no = new Option();
no.value = fbox;
no.text = fbox;
tbox.options[tbox.options. length] = no;
tbox.selectedIndex = no;
fbox= "";
if (sortitems) SortD(tbox);
}
function SortD(box) {
var temp_opts = new Array();
var temp = new Object();
for(var i=0; i<box.options.length; i++) {
temp_opts[i] = box.options[i];
}
for(var x=0; x<temp_opts.length-1; x++) {
for(var y=(x+1); y<temp_opts.length; y++) {
if(temp_opts[x].text > temp_opts[y].text) {
temp = temp_opts[x].text;
temp_opts[x].text = temp_opts[y].text;
temp_opts[y].text = temp;
}
}
}
for(var i=0; i<box.options.length; i++) {
box.options[i].value = temp_opts[i].value;
box.options[i].text = temp_opts[i].text;
}
}
// End -->
</script>
<%
dim dbConn
set dbConn = server.createobject("adodb .Connectio n")
dbConn.open Session("DATABASENORTHWIND ")
Set rs = Server.CreateObject("ADODB .Recordset ")
%>
</HEAD>
<BODY>
<form name="form1">
<input name="txtAssetTag" type="text" id="txtAssetTag">
<%Call CreateOption("list1","sele ct distinct FIRSTNAME from EMPLOYEES ","FIRSTNAME","FIRSTNAME", request("FIRSTNAME"))%>
<INPUT TYPE="button" VALUE="Add Item" onclick="callDialog()">
</form>
<%sub CreateOption(strName,strTa bleOrSQL,s trValue,st rDisplay, strSelected)
'This subroutine expects the following parameters:
' strName is the name of option to be created
' strTableNameOrSQL the name of table
' strValue is the field from the recordset that holds the value to be stored;
'strDisplay is the field from the recordset that will be displayed in the drop down;
'if a default value is to be selected, that is passed as strSelected. strJavaScript holds
'any event and script to be fired with that event.
dim objRSOption, strIsSelected
set objRSOption=Server.CreateO bject("ADO DB.RecordS et")
objRSOption.Open strTableOrSQL,dbConn
response.write("<Select Name = '" & strName & "'" & strJavaScript & ">")
response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & vbTab & "<Option Value = ''></Option>")
Do until objRSOption.eof
if Trim(UCase(objRSOption(str Value))) = Trim(UCase(strSelected)) then
strIsSelected = " selected"
else
strIsSelected = ""
end if
Response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & vbTab & "<Option" & strIsSelected & " Value ='" & objRSOption(strValue) & "'>" & objRSOption(strDisplay) & "</Option>")
objRSOption.MoveNext
Loop
Response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & "</Select>")
objRSOption.close
set objRSOption = Nothing
end sub%>
</BODY>
</HTML>
-----
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<HTML>
<HEAD>
<TITLE>callee.html</TITLE>
<SCRIPT>
function getInfoAndUpdate() {
var callerWindowObj = dialogArguments;
callerWindowObj.sColor = oEnterColor.value;
callerWindowObj.update();
}
function cancel() {
var callerWindowObj = dialogArguments;
callerWindowObj.sColor = "No Item";
callerWindowObj.update();
}
</SCRIPT>
</HEAD>
<BODY>
<INPUT VALUE="Ok" TYPE=button onclick="getInfoAndUpdate( );window.c lose();">
<INPUT VALUE="Cancel" TYPE=button onclick="cancel();window.c lose();">
<%
dim dbConn
set dbConn = server.createobject("adodb .Connectio n")
dbConn.open Session("DATABASENORTHWIND ")
Set rs = Server.CreateObject("ADODB .Recordset ")
%>
<style type="text/css">
<!--
.style3 {color: #336699; font-weight: bold; }
-->
</style>
</head>
<body>
<p align="center"> </p>
<p align="center"><strong>
<%
strSQL = "select * from Employees"
rs.CursorLocation = 3
rs.Open strSQL, dbConn, 3
rs.PageSize = 15 'Records per page
If Request.Querystring("page" ) = "" Then
myPage = 1
Else
myPage = Request.Querystring("page" )
End If
iPages = rs.PageCount
if iPages > 0 then
rs.AbsolutePage = myPage
else
response.write "No Employees"
response.end
end if
Count = 0
%>
<table border="1">
<tr bgcolor="#336699"><td><spa n class="BulletBackgroundCol or">Employ ee</span>< /td>
</tr>
<tr>
<%Do While Count < rs.PageSize And Not rs.EOF%>
<tr><td><%response.write rs("FirstName") %>
<%myvalue = rs("FirstName")%>
<input ID=oEnterColor value="<%=rs("FirstName")% >">
<INPUT VALUE="Ok" TYPE=button onclick="getInfoAndUpdate( );window.c lose();">
<a href='javascript:window.op ener.docum ent.form1. t.value=<% =rs("First Name")%>;s elf.close( )'>return 3></a>
</td>
<%Count = Count + 1
rs.MoveNext
Loop
%>
</table>
<%
If CInt(myPage) > 1 Then
%>
<a href="assetsearch.asp.asp? page=<%= myPage -1 %>">Prev</a>
<%
End If
If rs.PageCount > 1 Then
For i = 1 To rs.PageCount
%>
<a href="assetsearch.asp?page =<%= i %>"><%= i %></a>
<%
Next
End If
If CInt(myPage) < CInt(iPages) Then
%>
<a href="assetsearch.asp?page =<%= myPage +1 %>">Next</a>
<%
End If
%>
</body>
</HTML>
I post to this .....when i get that working
<a href="javascript:window.op
and returning to this
<input name=category>
<input type=button value=choose onclick=window.open("call_
The other javascript part is really good raj......but i think i have to get up to speed on javascript really quickly.
So i use the this example as it works....................a
As to populate the list drop down ..........(thats a luxury).
So i keep working on the other part......................
Thanks ........i close out the bug....
If i get a work around for this: using modal
<HEAD>
<TITLE>DialogArguments Example</TITLE>
<SCRIPT>
var sColor="";
function callDialog() {
showModelessDialog("callee
}
function update() {
fbox=sColor;
tbox = document.form1.list1;
<!-- Begin
sortitems = 1; // Automatically sort items within lists? (1 or 0)
var no = new Option();
no.value = fbox;
no.text = fbox;
tbox.options[tbox.options.
tbox.selectedIndex = no;
fbox= "";
if (sortitems) SortD(tbox);
}
function SortD(box) {
var temp_opts = new Array();
var temp = new Object();
for(var i=0; i<box.options.length; i++) {
temp_opts[i] = box.options[i];
}
for(var x=0; x<temp_opts.length-1; x++) {
for(var y=(x+1); y<temp_opts.length; y++) {
if(temp_opts[x].text > temp_opts[y].text) {
temp = temp_opts[x].text;
temp_opts[x].text = temp_opts[y].text;
temp_opts[y].text = temp;
}
}
}
for(var i=0; i<box.options.length; i++) {
box.options[i].value = temp_opts[i].value;
box.options[i].text = temp_opts[i].text;
}
}
// End -->
</script>
<%
dim dbConn
set dbConn = server.createobject("adodb
dbConn.open Session("DATABASENORTHWIND
Set rs = Server.CreateObject("ADODB
%>
</HEAD>
<BODY>
<form name="form1">
<input name="txtAssetTag" type="text" id="txtAssetTag">
<%Call CreateOption("list1","sele
<INPUT TYPE="button" VALUE="Add Item" onclick="callDialog()">
</form>
<%sub CreateOption(strName,strTa
'This subroutine expects the following parameters:
' strName is the name of option to be created
' strTableNameOrSQL the name of table
' strValue is the field from the recordset that holds the value to be stored;
'strDisplay is the field from the recordset that will be displayed in the drop down;
'if a default value is to be selected, that is passed as strSelected. strJavaScript holds
'any event and script to be fired with that event.
dim objRSOption, strIsSelected
set objRSOption=Server.CreateO
objRSOption.Open strTableOrSQL,dbConn
response.write("<Select Name = '" & strName & "'" & strJavaScript & ">")
response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & vbTab & "<Option Value = ''></Option>")
Do until objRSOption.eof
if Trim(UCase(objRSOption(str
strIsSelected = " selected"
else
strIsSelected = ""
end if
Response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & vbTab & "<Option" & strIsSelected & " Value ='" & objRSOption(strValue) & "'>" & objRSOption(strDisplay) & "</Option>")
objRSOption.MoveNext
Loop
Response.write(vbCrLF & vbTab & vbTab & vbTab & vbTab & "</Select>")
objRSOption.close
set objRSOption = Nothing
end sub%>
</BODY>
</HTML>
-----
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<HTML>
<HEAD>
<TITLE>callee.html</TITLE>
<SCRIPT>
function getInfoAndUpdate() {
var callerWindowObj = dialogArguments;
callerWindowObj.sColor = oEnterColor.value;
callerWindowObj.update();
}
function cancel() {
var callerWindowObj = dialogArguments;
callerWindowObj.sColor = "No Item";
callerWindowObj.update();
}
</SCRIPT>
</HEAD>
<BODY>
<INPUT VALUE="Ok" TYPE=button onclick="getInfoAndUpdate(
<INPUT VALUE="Cancel" TYPE=button onclick="cancel();window.c
<%
dim dbConn
set dbConn = server.createobject("adodb
dbConn.open Session("DATABASENORTHWIND
Set rs = Server.CreateObject("ADODB
%>
<style type="text/css">
<!--
.style3 {color: #336699; font-weight: bold; }
-->
</style>
</head>
<body>
<p align="center"> </p>
<p align="center"><strong>
<%
strSQL = "select * from Employees"
rs.CursorLocation = 3
rs.Open strSQL, dbConn, 3
rs.PageSize = 15 'Records per page
If Request.Querystring("page"
myPage = 1
Else
myPage = Request.Querystring("page"
End If
iPages = rs.PageCount
if iPages > 0 then
rs.AbsolutePage = myPage
else
response.write "No Employees"
response.end
end if
Count = 0
%>
<table border="1">
<tr bgcolor="#336699"><td><spa
</tr>
<tr>
<%Do While Count < rs.PageSize And Not rs.EOF%>
<tr><td><%response.write rs("FirstName") %>
<%myvalue = rs("FirstName")%>
<input ID=oEnterColor value="<%=rs("FirstName")%
<INPUT VALUE="Ok" TYPE=button onclick="getInfoAndUpdate(
<a href='javascript:window.op
</td>
<%Count = Count + 1
rs.MoveNext
Loop
%>
</table>
<%
If CInt(myPage) > 1 Then
%>
<a href="assetsearch.asp.asp?
<%
End If
If rs.PageCount > 1 Then
For i = 1 To rs.PageCount
%>
<a href="assetsearch.asp?page
<%
Next
End If
If CInt(myPage) < CInt(iPages) Then
%>
<a href="assetsearch.asp?page
<%
End If
%>
</body>
</HTML>
I post to this .....when i get that working
Are you getting the List (option) values from the database for second page(child). If so work on displaying all values to the drop down list some thing like:
<select name = "oEnterValue">
>query and get resultset
>check for the end of rs i.e. loop
>get the value i.e. myvalue = rs("FirstName")
<option value = <=%myvalue%>><%myvalue%></ option>
repeat untill get all values.
</select>
do this and let me know if you are able to display all values in the drop down box..
-Raj
<select name = "oEnterValue">
>query and get resultset
>check for the end of rs i.e. loop
>get the value i.e. myvalue = rs("FirstName")
<option value = <=%myvalue%>><%myvalue%></
repeat untill get all values.
</select>
do this and let me know if you are able to display all values in the drop down box..
-Raj
Once you are able to get that working then use this. I got this one working with drop down list on child page..
<HTML>
<HEAD>
<TITLE>callee.html</TITLE>
<SCRIPT>
function getInfoAndUpdate() {
var callerWindowObj = dialogArguments;
callerWindowObj.sColor = oEnterColor.value;
callerWindowObj.update();
}
function cancel() {
var callerWindowObj = dialogArguments;
callerWindowObj.sColor = "";
callerWindowObj.update();
}
</SCRIPT>
</HEAD>
<BODY>
<select name="oEnterColor">
<option value="One">One</option>
<option value="Two">Two</option>
<option value="Three">Three</optio n>
</select>
<INPUT VALUE="Ok" TYPE=button onclick="getInfoAndUpdate( );window.c lose();">
<INPUT VALUE="Cancel" TYPE=button onclick="cancel();window.c lose();">
</BODY>
</HTML>
===================
drop down part will be replaced with your working part i.e.
<select name = "oEnterValue">
<%
>query and get resultset
>check for the end of rs i.e. loop
>get the value i.e. myvalue = rs("FirstName") %>
<option value = <=%myvalue%>><%=myvalue%>< /option>
<%repeat untill get all values.%>
</select>
=========================
This will work...
<HTML>
<HEAD>
<TITLE>callee.html</TITLE>
<SCRIPT>
function getInfoAndUpdate() {
var callerWindowObj = dialogArguments;
callerWindowObj.sColor = oEnterColor.value;
callerWindowObj.update();
}
function cancel() {
var callerWindowObj = dialogArguments;
callerWindowObj.sColor = "";
callerWindowObj.update();
}
</SCRIPT>
</HEAD>
<BODY>
<select name="oEnterColor">
<option value="One">One</option>
<option value="Two">Two</option>
<option value="Three">Three</optio
</select>
<INPUT VALUE="Ok" TYPE=button onclick="getInfoAndUpdate(
<INPUT VALUE="Cancel" TYPE=button onclick="cancel();window.c
</BODY>
</HTML>
===================
drop down part will be replaced with your working part i.e.
<select name = "oEnterValue">
<%
>query and get resultset
>check for the end of rs i.e. loop
>get the value i.e. myvalue = rs("FirstName") %>
<option value = <=%myvalue%>><%=myvalue%><
<%repeat untill get all values.%>
</select>
=========================
This will work...
Thanks Dr. Fairfield, if you didn't have question about being this done with JavaScript, we would have not tried..
Happy to help but you did most of the heavy lifting.
Doc (a.ka. FtB)
Doc (a.ka. FtB)
ASKER
raj3060 just tried it....works a treat............
Javascript is pretty neat and powerful ......never knew it ......
So for me to learn its just "javascript" thats whats i need to get book or course on
I appreciate you sticking with a newbie in javascript here..
Now weekend i can take code home and go over it.
Cheers
Javascript is pretty neat and powerful ......never knew it ......
So for me to learn its just "javascript" thats whats i need to get book or course on
I appreciate you sticking with a newbie in javascript here..
Now weekend i can take code home and go over it.
Cheers
ASKER
One last question.
What application you using to write your javascript in...
So that you see the object.x.come up
like when i type in response. i get promted with list of values whilst typing
cheers
What application you using to write your javascript in...
So that you see the object.x.come up
like when i type in response. i get promted with list of values whilst typing
cheers
You can write in Note pad or any text editor. Nothing special is required. The only problem with JavaScript is that if you rely on it, and the person has it disabled in the browser, then you may find yourself in trouble.
FtB
FtB
FtB is right, you can use any free editors available out there, I use HTMLKit, it's pretty neat, it has a nice feature that checks your code for any error, and or completes your code if you forgot something somewhere in the code. Doc is right about JavaScript too, because it is not compatible on all browsers, and acts real funky sometimes. I try to stay away from it as much as I can, because stuff you can do with JavaScript you can do with ASP or JSP too, and that's more reliable.
Stuff we did is not that easy, because I tried to do something like that before, could not do it. I learnt something new too.
You are welcome, and feel free to ask any question in future.
Have a nice weekend to you and FtB.
-raj
Stuff we did is not that easy, because I tried to do something like that before, could not do it. I learnt something new too.
You are welcome, and feel free to ask any question in future.
Have a nice weekend to you and FtB.
-raj
FtB