Problems with dropdown list

C

carmen

I am having a problem with the code below. When the page loads the data it
is pulled from the db just fine. But when I try to update the dropdown list
that has the onchange added to it is not working. Am I leaving something
out.
Any suggestions would be appreciated.

Thanks
Carmen

<SCRIPT>
function UpdateSample1()
{
var CallTypSelect = document.forms.FrontPage_Form1.CallTyp;
var SeveritySelect = document.forms.FrontPage_Form1.Severity;

SeveritySelect.options.length = 0; // Clear the popup

if (CallTypSelect.options[CallTypSelect.selectedIndex].value == "Question")
{
SeveritySelect.options[0] = new Option(" ");
}
else if (CallTypSelect.options[CallTypSelect.selectedIndex].value ==
"Other")
{
SeveritySelect.options[0] = new Option(" ");
}
else if (CallTypSelect.options[CallTypSelect.selectedIndex].value ==
"Problem")
{
SeveritySelect.options[0] = new Option("S1");
SeveritySelect.options[1] = new Option("S2");
}
}
</SCRIPT>


<form method="POST" action="submitupdate.asp" onsubmit="return
FrontPage_Form1_Validator(this)" language="JavaScript"
name="FrontPage_Form1">
<td width="34%" height="22"><b>
<select size="1" name="CallTyp" onchange="UpdateSample1()">
<option selected><%=RSupdate("CallTyp")%></option>
<%
If RSupdate("CallTyp")= "Question" then
%>
<option>Other</option>
<option>Problem</option>
<% end if %>
<%
if RSupdate("CallTyp")= "Other" Then
%>
<option>Question</option>
<option>Problem</option>
<% end if %>
<%
if RSupdate("CallTyp")= "Problem" Then
%>
<option>Question</option>
<option>Other</option>
<%
End if
%>
</select></b></td>

<td width="34%" height="22"><b>
<%
if RSupdate("Severity1")="S1" then
sever1 ="S1"
End if
if RSupdate("Severity2")="S2" then
sever1 ="S2"
End if
%>
<select size="1" name="Severity">
<option selected> <%=Sever1%></option>
</select></b>
</td>
 
J

Jim Buyens

Yes, you're leaving out the value= attributes in your
<option> tags. You need to code

<option value="Problem">Problem</option>

if you want

CallTypSelect.options[CallTypSelect.selectedIndex].value

to return a non-empty value.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------


-----Original Message-----
I am having a problem with the code below. When the page
loads the data it is pulled from the db just fine. But
when I try to update the dropdown list that has the
onchange added to it is not working. Am I leaving
something out.
Any suggestions would be appreciated.

Thanks
Carmen

<SCRIPT>
function UpdateSample1()
{
var CallTypSelect = document.forms.FrontPage_Form1.CallTyp;
var SeveritySelect = document.forms.FrontPage_Form1.Severity;

SeveritySelect.options.length = 0; // Clear the popup

if (CallTypSelect.options
[CallTypSelect.selectedIndex].value == "Question")
{
SeveritySelect.options[0] = new Option(" ");
}
else if (CallTypSelect.options
[CallTypSelect.selectedIndex].value ==
"Other")
{
SeveritySelect.options[0] = new Option(" ");
}
else if (CallTypSelect.options
[CallTypSelect.selectedIndex].value ==
"Problem")
{
SeveritySelect.options[0] = new Option("S1");
SeveritySelect.options[1] = new Option("S2");
}
}
</SCRIPT>


<form method="POST" action="submitupdate.asp" onsubmit="return
FrontPage_Form1_Validator(this)" language="JavaScript"
name="FrontPage_Form1">
<td width="34%" height="22"><b>
<select size="1" name="CallTyp" onchange="UpdateSample1 ()">
<option selected><%=RSupdate("CallTyp")%></option>
<%
If RSupdate("CallTyp")= "Question" then
%>
<option>Other</option>
<option>Problem</option>
<% end if %>
<%
if RSupdate("CallTyp")= "Other" Then
%>
<option>Question</option>
<option>Problem</option>
<% end if %>
<%
if RSupdate("CallTyp")= "Problem" Then
%>
<option>Question</option>
<option>Other</option>
<%
End if
%>
</select></b></td>

<td width="34%" height="22"><b>
<%
if RSupdate("Severity1")="S1" then
sever1 ="S1"
End if
if RSupdate("Severity2")="S2" then
sever1 ="S2"
End if
%>
<select size="1" name="Severity">
<option selected> <%=Sever1%></option>
</select></b>
</td>



.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top