• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 738
  • Last Modified:

Java script needed to reset list boxes from selection in another list box

Hi
I have an update form with 3 list boxes (See Snipped). I was wondering is it possible to use Java Script to reset listbox 2 and 3 to display "Select" depending on the selection in box 1. If Insert is selected in box (1) list box's 2 and 3 should remain displaying info ,however if "Remove" is selected I was hoping to reset listboxes 2 and 3 to display "select" which on form submit would erase info from my table??

Select sends ""  Blank to my table
Thank You
Is Split Billing to be Removed or Inserted :<br>
<select name="insert_remove" id="choice" onChange="ShowReg(this.selectedIndex);MM_popupMsg('If you intend changing to Remove please choose SELECT in the Dropdown menus below .\r\rThank You')">
                   <option value="0" <%If (Not isNull((Recordset1.Fields.Item("Remove_Insert").Value))) Then If ("0" = CStr((Recordset1.Fields.Item("Remove_Insert").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>Select
                   <option value="Insert" <%If (Not isNull((Recordset1.Fields.Item("Remove_Insert").Value))) Then If ("Insert" = CStr((Recordset1.Fields.Item("Remove_Insert").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>Insert
                   <option value="Remove" <%If (Not isNull((Recordset1.Fields.Item("Remove_Insert").Value))) Then If ("Remove" = CStr((Recordset1.Fields.Item("Remove_Insert").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>Remove
                  </select>
<br>
<br>
            <div align="center">Who is to be charged the early cease fee<br>
            <select name="SOC_ECF_Ind" id="SOC_ECF_Ind">
             <option value=" " selected <%If (Not isNull((Recordset1.Fields.Item("SOC_ECF_Ind").Value))) Then If (" " = CStr((Recordset1.Fields.Item("SOC_ECF_Ind").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>Select</option>
             <option value="Y" <%If (Not isNull((Recordset1.Fields.Item("SOC_ECF_Ind").Value))) Then If ("Y" = CStr((Recordset1.Fields.Item("SOC_ECF_Ind").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>Corporate</option>
             <option value="" <%If (Not isNull((Recordset1.Fields.Item("SOC_ECF_Ind").Value))) Then If ("" = CStr((Recordset1.Fields.Item("SOC_ECF_Ind").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>E-worker</option>
            </select>
            <br>
            <br>
&nbsp;Select e-worker/corportate method of billing:&nbsp;<span class="style1"><br>
</span>
<select name="DSL_SOC_Ind" id="DSL_SOC_Ind">
 <option value=" " selected <%If (Not isNull((Recordset1.Fields.Item("DSL_SOC_Ind").Value))) Then If (" " = CStr((Recordset1.Fields.Item("DSL_SOC_Ind").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>Select</option>
 <option value="D" <%If (Not isNull((Recordset1.Fields.Item("DSL_SOC_Ind").Value))) Then If ("D" = CStr((Recordset1.Fields.Item("DSL_SOC_Ind").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>Corp pays for DSL e-worker socs </option>
 <option value="V" <%If (Not isNull((Recordset1.Fields.Item("DSL_SOC_Ind").Value))) Then If ("V" = CStr((Recordset1.Fields.Item("DSL_SOC_Ind").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>Corp pays for VPN e-worker socs</option>
 <option value="A" <%If (Not isNull((Recordset1.Fields.Item("DSL_SOC_Ind").Value))) Then If ("A" = CStr((Recordset1.Fields.Item("DSL_SOC_Ind").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>Corp pays for all e-worker socs</option>
           </select>

Open in new window

0
Camnoc
Asked:
Camnoc
  • 4
  • 3
  • 2
1 Solution
 
busbusCommented:
add this to the function.
      function ShowReg(args){
            if(document.all["insert_remove"].selectedIndex == 2){
                  document.all["SOC_ECF_Ind"].options[0].selected = true;
                  document.all["DSL_SOC_Ind"].options[0].selected = true;
            }
      }
0
 
CamnocAuthor Commented:
My java script knowledge is very limited, how do I add to function
0
 
busbusCommented:
<HTML>
 <HEAD>
 </HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
      put here the function
//-->
</SCRIPT>
 <BODY>
 </BODY>
</HTML>
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
CamnocAuthor Commented:
Hi
I have done exactly as you said  The Java Script is inserted in the head but nothing happening. Should something be added to the insert-remove selection box??? ie On change action ?

Paul
0
 
busbusCommented:
<BODY>
put here the code with the selection boxs.
</BODY>

ie.
<BODY>
<select name="insert_remove" id="choice" onChange="ShowReg(this.selectedIndex);MM_popupMsg('If you intend changing to Remove please choose SELECT in the Dropdown menus below .\r\rThank You')">
                   <option value="0" <%If (Not isNull((Recordset1.Fields.Item("Remove_Insert").Value))) Then If ("0" = CStr((Recordset1.Fields.Item("Remove_Insert").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>Select
                   <option value="Insert" <%If (Not isNull((Recordset1.Fields.Item("Remove_Insert").Value))) Then If ("Insert" = CStr((Recordset1.Fields.Item("Remove_Insert").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>Insert
                   <option value="Remove" <%If (Not isNull((Recordset1.Fields.Item("Remove_Insert").Value))) Then If ("Remove" = CStr((Recordset1.Fields.Item("Remove_Insert").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>Remove
                  </select>
...
...
...
..
</BODY>
0
 
Michel PlungjanIT ExpertCommented:
Do not use document.all - it is IE only

Change the code to


Is Split Billing to be Removed or Inserted :<br>
<select name="insert_remove" id="choice" 
onChange="ShowReg(this.selectedIndex);
if (this.options[this.selectedIndex].value=='Remove'){
this.form.SOC_ECF_Ind.selectedIndex=0;
this.form.DSL_SOC_Ind.selectedIndex=0;
}">
 

Open in new window

0
 
CamnocAuthor Commented:
Thank you
Works like a dream

Paul
0
 
Michel PlungjanIT ExpertCommented:
???
0
 
CamnocAuthor Commented:
Thank you My company only uses IE but worth knowing

Paul
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now