PDA

View Full Version : pass selected item within the form


tommylu
09-20-2007, 01:13 AM
Hi,

I tried to pass a selected item value within a form. Can anyone help? Thanks.

Tommy,

<%@LANGUAGE="JAVASCRIPT ('%@LANGUAGE="JAVASCRIPT')" CODEPAGE="1252"%>
<!--#include file="Connections/ChinesePLC.asp" -->
<%
var rstCategory = Server.CreateObject("ADODB.Recordset");
rstCategory.ActiveConnection = MM_ChinesePLC_STRING;
rstCategory.Source = "SELECT Category, CID FROM Category_Tab";
rstCategory.CursorType = 0;
rstCategory.CursorLocation = 2;
rstCategory.LockType = 1;
rstCategory.Open();
var rstCategory_numRows = 0;
function getCategory(myForm)
{
document.CatForm.Category.value = myForm.Category.value;
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>test page</title>
</head>
[b]
<form name="CategoryList">
<select name="Category" onchange="getCategory(CategoryList)" size="1">
<option value="0">Select a category</option>
<%
while (!rstCategory.EOF) {
%>
<option value="<%=(rstCategory.Fields.Item("Category").Value)%>"><%=(rstCategory.Fields.Item("Category").Value)%></option>
<%
rstCategory.MoveNext();
}
if (rstCategory.CursorType > 0) {
if (!rstCategory.BOF) rstCategory.MoveFirst();
} else {
rstCategory.Requery();
}
%>
</select>
</form>
<form name="CatForm" method="get">
<input type="text" name="Category" value="" />
</form>
</body>
</html>
<%
rstCategory.Close();
%>