RE: Using Selectedindex value for calculations

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Skydolphin (anonymous_at_discussions.microsoft.com)
Date: 04/21/04


Date: Wed, 21 Apr 2004 13:06:06 -0700

I prefer javascript to do this but that's my preference. This would work I just tested it. Put the onchange call on the dropdown. onchange="doCalc();"
<script language="javascript">
function doCalc()
{
var firstvalue = document.all("drop1")(document.all("drop1").selectedIndex).text;

var secondvalue = document.all("drop2")(document.all("drop2").selectedIndex).text;

document.all("Text1").value = parseInt(firstvalue) + parseInt(secondvalue);

}

</script><select size="1" name="drop1" onchange="doCalc();"><option value="1">1</option><option value="2">2</option></select><select size="1" name="drop2" onchange="doCalc();"><option value="1">1</option><option value="2">2</option></select><input type="text" name="Text1" value="">

Rhonda



Relevant Pages

  • Re: IE 6 & Norton
    ... weren't seeing the dropdown menu for the NCAA FOOTBALL header. ... Besides the script source contained in the HTML page there are also ... > uninstall NIS and restart I still have the same problem. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: An oddity when clicking checkbox
    ... Don't use onchange, use ... If client-side script support is not present or disabled, ... evangelism: XHTML 1.0 Strict ...
    (comp.lang.javascript)
  • Re: onchange not sufficient to handle changes in a frame
    ... onchange event. ... if you use onchange, ... tab over to the dropdown and click the down arrow. ... The dropdown list box handles the keyboard automatically. ...
    (microsoft.public.frontpage.programming)
  • Re: right margin info
    ... you have to quit Entourage ... pretty disruptive - a script does not make it less so, ... keep the Display Complex HTML preference OFF. ...
    (microsoft.public.mac.office.entourage)
  • RE: text truncation in dropdownlist control
    ... the dropdown is populated via a database table and so ... to html client side script coding. ... > dosn't support the ToolTip feature. ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)