PDA

View Full Version : DropDown List - XML, ASP and Javascript needs help


ClueLess
03-19-2003, 05:42 PM
it's sad that no body answer my question. Regarding to my previous question- I get the
xml works in asp. I need your help - how can I change the value in the textboxes when I selected different item from the dropdown list?

previous question: “I have a dropdown box; we can select diff. value from the dropdown list…. Any values in that dd’s list group (or belongs to that dd’s item), please the XML tree, they will display in the textboxes. How can I do that?“

Hope, some of you know.......


==XML and ASP CODE========
<%@ language="VBScript" %>
<% option explicit %>

<%
'Create DOMdocument. Instantiatate the XML Processor
Set objXML = Server.CreateObject("MSXML.DOMDocument")

if err then
Response.Write "<font color=red><b>2. LU_PIP.asp " & Err.description & "</b><font>"
Response.End
end if

'Load the XML Document. Temporary we load it in LU_Gender.xml
objXML.load(Server.MapPath("LU_PIP.xml"))

'Assing XML string from DOM Document into XML root node.
Set objRootElement = objXML.documentElement

if err then
Response.write "<center><font=red><b>4. LU_PIP.asp " & Err.description & "</b></font></center>"
Response.End
end if

err.Clear

Set objStateNode = objRootElement.selectSingleNode("STATE")

Set objPIPCode1 = objStateNode.selectSingleNode("PIPCODE1")
Set objPlan = objPIPCode1.selectSingleNode("PLAN")
Set objMaxMedExp = objPlan.selectSingleNode("MAXMEDEXP")
Set objMaxNonMedExp = objPlan.selectSingleNode("MAXNONMEDEXP")
Set objMaxWorkLoss = objPlan.selectSingleNode("MAXWORKLOSS")

MaxMedExpNode = objMaxMedExp.attributes.getNamedItem("Value").nodeValue
MaxMedExpNodeText = objMaxMedExp.attributes.getNamedItem("Text").nodeValue

MaxNonMedExpNode = objMaxNonMedExp.attributes.getNamedItem("Value").nodeValue
MaxNonMedExpNodeText = objMaxNonMedExp.attributes.getNamedItem("Text").nodeValue

MaxWorkLossNode = objMaxWorkLoss.attributes.getNamedItem("Value").nodeValue
MaxWorkLossNodeText = objMaxWorkLoss.attributes.getNamedItem("Text").nodeValue


%> <html>
<Body>
<table>
<tr>
<td>
Plan Type
</td>
<td>
<select name="plantype">
<% for each objPlan in objPIPCode1.childNodes %>
<% PIPplantype = objPlan.attributes.getNamedItem("PIPplantype").nodeValue%>
<option value="<%=PIPplantype %>"> <%=PIPplantype%></option>
<%next %>
</select>
</td>

<tr>
<td class="SmallHeadingBurg" width="180"> Medical Expense:&nbsp;</td>
<td class="regularParagraph" align="left">$
<SELECT size=1 id="MaxMedExp" name="MaxMedExp" multiple>
<OPTION value="<%=MaxMedExpNode%>"><%=MaxMedExpNodeText%></OPTION>
</SELECT>
</td>
</tr>
<tr>
<td class="SmallHeadingBurg" width="180">Non-Med Expense:&nbsp;</td>
<td class="regularParagraph" align="left">$
<SELECT size=1 id="MaxNonMedExp" name="MaxNonMedExp" multiple>
<OPTION value="<%=MaxNonMedExpNode%>" ><%=MaxNonMedExpNodeText%></OPTION>
</SELECT>
</td>
</tr>
<tr>
<td class="SmallHeadingBurg" width="180">Work Loss:&nbsp;</td>
<td class="regularParagraph" align="left">$
<SELECT size=1 id="MaxWorkLoss" name="MaxWorkLoss" multiple>
<OPTION value="<%=MaxWorkLossNode%>" ><%=MaxWorkLossNodeText%></OPTION>
</SELECT>
</td>
</tr>


</table>

<%
'Free server resources associated with the instance.
'Set DomDoc = Nothing
Set objXML = Nothing
Set objStateNode = Nothing
Set DataNodes = Nothing
Set objPIPCode1 = Nothing
Set objPlan = Nothing
Set objMaxMedExp = Nothing
Set objMaxNonMedExp = Nothing
Set objMaxWorkLoss = Nothing

Set WorkLossNodes = Nothing
%>
</Body>
</Html>

=========XML TREE===========
<?xml version="1.0"?>
<PIP>
<STATE Id="4" Name="California">
<PIPCODE1>
<PLAN PIPplantype="PLAN A">
<MAXMEDEXP Value="20000" Text="20,000" />
<MAXNONMEDEXP Value="20000" Text="20,000" />
<MAXWORKLOSS Value="250" Text="250" />
</PLAN>
<PLAN PIPplantype="PLAN B">
<MAXMEDEXP Value="30000" Text="30,000" />
<MAXNONMEDEXP Value="20000" Text="20,000" />
<MAXWORKLOSS Value="250" Text="250" />
</PLAN>
<PLAN PIPplantype="PLAN C" >
<MAXMEDEXP Value="40000" Text="40,000" />
<MAXNONMEDEXP Value="20000" Text="20,000" />
<MAXWORKLOSS Value="250" Text="250" />
</PLAN>
<PLAN PIPplantype="PLAN D">
<MAXMEDEXP Value="50000" Text="50,000" />
<MAXNONMEDEXP Value="20000" Text="20,000" />
<MAXWORKLOSS Value="250" Text="250" />
</PLAN>
<PLAN PIPplantype="PLAN E">
<MAXMEDEXP Value="50000" Text="50,000" />
<MAXNONMEDEXP Value="35000" Text="35,000" />
<MAXWORKLOSS Value="350" Text="350" />
</PLAN>
</PIPCODE1>

</STATE>
</PIP>

glenngv
03-20-2003, 01:37 AM
you need a double combo script (http://www.javascriptkit.com/script/cut183.shtml).