Click here to Skip to main content
15,918,617 members
Home / Discussions / Web Development
   

Web Development

 
Questionvalign equivalent in CSS? Pin
Jörgen Sigvardsson13-Mar-03 3:23
Jörgen Sigvardsson13-Mar-03 3:23 
AnswerRe: valign equivalent in CSS? Pin
Richard Deeming13-Mar-03 6:07
mveRichard Deeming13-Mar-03 6:07 
GeneralRe: valign equivalent in CSS? Pin
Jörgen Sigvardsson13-Mar-03 11:11
Jörgen Sigvardsson13-Mar-03 11:11 
GeneralRe: valign equivalent in CSS? Pin
Paul Watson16-Mar-03 22:43
sitebuilderPaul Watson16-Mar-03 22:43 
GeneralRe: valign equivalent in CSS? Pin
Jörgen Sigvardsson16-Mar-03 22:59
Jörgen Sigvardsson16-Mar-03 22:59 
GeneralRe: valign equivalent in CSS? Pin
Paul Watson16-Mar-03 23:09
sitebuilderPaul Watson16-Mar-03 23:09 
GeneralRe: valign equivalent in CSS? Pin
Jörgen Sigvardsson17-Mar-03 0:04
Jörgen Sigvardsson17-Mar-03 0:04 
GeneralDynamic List Boxes w/Access/ASP/Javascript Pin
John Lysfjord12-Mar-03 20:11
sussJohn Lysfjord12-Mar-03 20:11 
Been scratching my head for too long now, so I hope there are someone out there who can tell me how to do this:

What I got:
I got an Access database with two tables, one for productcategories and one for products. In the products table I also got a unit price column.

On a webpage I got a form with two dropdown boxes and a textfield.


What I am doing:
The first dropdown box dynamically displays product categories via VBscript. No problem. The second dropdown box dynamically shows products in the selected product category. (No need to reload page as I use a Javascript array to store every possible value. It's not a big database).


What I want to do:
I need the price to dynamically show up in the textfield when a product has been selected.

I know the theory behind it. I need to load all the prices into a Javascript array from the database... but I can't understand how this is done in the code. (I mainly copied and pasted the code I got so far).

Copy of successful code below, anyone that could tell me how I can get the prices into an array and make them appear in a textfield?

Cheers

John


--- CODE ------------

<%@LANGUAGE="VBSCRIPT" CODEPAGE="950"%>
<!--#include file="Connections/CoffeeDarts.asp" -->
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_CoffeeDarts_STRING
Recordset1.Source = "SELECT ProductType FROM ProductType"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
Dim rslist2
Dim rslist2_numRows

Set rslist2 = Server.CreateObject("ADODB.Recordset")
rslist2.ActiveConnection = MM_CoffeeDarts_STRING
rslist2.Source = "SELECT ProductType, ProductName FROM Products"
rslist2.CursorType = 0
rslist2.CursorLocation = 2
rslist2.LockType = 1
rslist2.Open()

rslist2_numRows = 0
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=big5">

<!-- Dynamic Dependent List box Code for *** VBScript *** Server Model //-->
<script language="JavaScript">
<!--

var arrDynaList = new Array();
var arrDL1 = new Array();

arrDL1[1] = "selList1"; // Name of parent list box
arrDL1[2] = "form1"; // Name of form containing parent list box
arrDL1[3] = "selList2"; // Name of child list box
arrDL1[4] = "form1"; // Name of form containing child list box
arrDL1[5] = arrDynaList;

<%
Dim txtDynaListRelation, txtDynaListLabel, txtDynaListValue, oDynaListRS

txtDynaListRelation = "ProductType" ' Name of recordset field relating to parent
txtDynaListLabel = "ProductName" ' Name of recordset field for child Item Label
txtDynaListValue = "ProductName" ' Name of recordset field for child Value
Set oDynaListRS = rsList2 ' Name of child list box recordset

Dim varDynaList
varDynaList = -1

Dim varMaxWidth
varMaxWidth = "1"

Dim varCheckGroup
varCheckGroup = oDynaListRS.Fields.Item(txtDynaListRelation).Value

Dim varCheckLength
varCheckLength = 0

Dim varMaxLength
varMaxLength = 0

While (NOT oDynaListRS.EOF)

If (varCheckGroup <> oDynaListRS.Fields.Item(txtDynaListRelation).Value) Then
If (varCheckLength > varMaxLength) Then
varMaxLength = varCheckLength
End If
varCheckLength = 0
End If
%>
arrDynaList[<%=(varDynaList+1)%>] = "<%=(oDynaListRS.Fields.Item(txtDynaListRelation).Value)%>"
arrDynaList[<%=(varDynaList+2)%>] = "<%=(oDynaListRS.Fields.Item(txtDynaListLabel).Value)%>"
arrDynaList[<%=(varDynaList+3)%>] = "<%=(oDynaListRS.Fields.Item(txtDynaListValue).Value)%>"
<%
If (len(oDynaListRS.Fields.Item(txtDynaListLabel).Value) > len(varMaxWidth)) Then
varMaxWidth = oDynaListRS.Fields.Item(txtDynaListLabel).Value
End If
varCheckLength = varCheckLength + 1
varDynaList = varDynaList + 3
oDynaListRS.MoveNext()
Wend

If (varCheckLength > varMaxLength) Then
varMaxLength = varCheckLength
End If
%>

//-->
</script>

<!-- End of object/array definitions, beginning of generic functions -->

<script language="JavaScript">
<!--
function setDynaList(arrDL){

var oList1 = document.forms[arrDL[2]].elements[arrDL[1]];
var oList2 = document.forms[arrDL[4]].elements[arrDL[3]];
var arrList = arrDL[5];

clearDynaList(oList2);

if (oList1.selectedIndex == -1){
oList1.selectedIndex = 0;
}

populateDynaList(oList2, oList1[oList1.selectedIndex].value, arrList);
return true;
}

function clearDynaList(oList){

for (var i = oList.options.length; i >= 0; i--){
oList.options[i] = null;
}

oList.selectedIndex = -1;
}

function populateDynaList(oList, nIndex, aArray){

for (var i = 0; i < aArray.length; i= i + 3){
if (aArray[i] == nIndex){
oList.options[oList.options.length] = new Option(aArray[i + 1], aArray[i + 2]);
}
}

if (oList.options.length == 0){
oList.options[oList.options.length] = new Option("[none available]",0);
}

oList.selectedIndex = 0;
}

function MM_callJS(jsStr) { //v2.0
return eval(jsStr)
}
//-->
</script>



</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_callJS('setDynaList(arrDL1)')">
<form name="form1" method="post" action="">
<table width="1000" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/spacer.gif" alt="" width="100" height="1"></td>
<td><img src="images/spacer.gif" alt="" width="120" height="1"></td>
<td><img src="images/spacer.gif" alt="" width="120" height="1"></td>
<td><img src="images/spacer.gif" alt="" width="100" height="1"></td>
<td><img src="images/spacer.gif" alt="" width="100" height="1"></td>
<td><img src="images/spacer.gif" alt="" width="100" height="1"></td>
<td><img src="images/spacer.gif" alt="" width="100" height="1"></td>
<td><img src="images/spacer.gif" alt="" width="100" height="1"></td>
</tr>
<tr>
<td><font color="#844B00" size="3" face="Arial, Helvetica, sans-serif">
<input name="quantity" type="text" id="quantity" size="5">
</font></td>
<td><select name="selList1" id="select" onChange="MM_callJS('setDynaList(arrDL1)')">
<%
While (NOT Recordset1.EOF)
%>
<option value="<%=(Recordset1.Fields.Item("ProductType").Value)%>"><%=(Recordset1.Fields.Item("ProductType").Value)%></option>
<%
Recordset1.MoveNext()
Wend
If (Recordset1.CursorType > 0) Then
Recordset1.MoveFirst
Else
Recordset1.Requery
End If
%>
</select></td>
<td><select name="selList2" id="select2">
</select></td>
<td><font color="#844B00" size="3" face="Arial, Helvetica, sans-serif">NT
<input name="unitPrice" type="text" id="unitPrice" size="6">
</font></td>
<td><font color="#844B00" size="3" face="Arial, Helvetica, sans-serif">
<input name="voucher" type="text" id="voucher" size="5">
&#24373; </font></td>
<td><font color="#844B00" size="3" face="Arial, Helvetica, sans-serif">
<input name="refilled" type="text" id="refilled" size="5">
&#27425;</font></td>
<td><font color="#844B00" size="3" face="Arial, Helvetica, sans-serif">
<input name="discount" type="text" id="voucher3" size="5">
%</font></td>
<td><font color="#844B00" size="3" face="Arial, Helvetica, sans-serif">NT
<input name="subTotal" type="text" id="subTotal" size="6">
</font></td>
</tr>
</table>
</form>

</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
<%
rslist2.Close()
Set rslist2 = Nothing
%>Confused | :confused:
Generalopening 2 instances of web browser with different dialup settings Pin
doddakiran12-Mar-03 2:55
doddakiran12-Mar-03 2:55 
GeneralAutomatic updates Pin
Brakanjan12-Mar-03 1:30
Brakanjan12-Mar-03 1:30 
GeneralRe: Automatic updates Pin
Jonathan32112-Mar-03 17:34
Jonathan32112-Mar-03 17:34 
GeneralRe: Automatic updates Pin
Brakanjan12-Mar-03 20:20
Brakanjan12-Mar-03 20:20 
GeneralRe: Automatic updates Pin
SimonS19-Mar-03 22:48
SimonS19-Mar-03 22:48 
GeneralRe: Automatic updates Pin
Vasudevan Deepak Kumar14-Mar-03 3:21
Vasudevan Deepak Kumar14-Mar-03 3:21 
GeneralRe: Automatic updates Pin
Jonavis20-Mar-03 22:01
Jonavis20-Mar-03 22:01 
GeneralHelp! can't get the return value Pin
Anonymous12-Mar-03 0:22
Anonymous12-Mar-03 0:22 
GeneralWeb Services Deployment : Referenced Assembly Location Pin
John Pelz11-Mar-03 14:07
John Pelz11-Mar-03 14:07 
GeneralWeb Service Pin
User 988511-Mar-03 12:28
User 988511-Mar-03 12:28 
GeneralRe: Web Service Pin
Chris Maunder11-Mar-03 13:32
cofounderChris Maunder11-Mar-03 13:32 
GeneralRe: Web Service Pin
User 988511-Mar-03 13:48
User 988511-Mar-03 13:48 
GeneralRe: Web Service Pin
Jörgen Sigvardsson13-Mar-03 3:24
Jörgen Sigvardsson13-Mar-03 3:24 
GeneralRe: Web Service Pin
User 988513-Mar-03 3:29
User 988513-Mar-03 3:29 
GeneralRe: Web Service Pin
Jörgen Sigvardsson13-Mar-03 3:36
Jörgen Sigvardsson13-Mar-03 3:36 
GeneralRe: Web Service Pin
User 988513-Mar-03 3:48
User 988513-Mar-03 3:48 
GeneralRe: Web Service Pin
Ryan_Roberts13-Mar-03 3:55
Ryan_Roberts13-Mar-03 3:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.