Solved

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

Posted on 2008-06-26
9
721 Views
Last Modified: 2010-04-21
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
Comment
Question by:Camnoc
  • 4
  • 3
  • 2
9 Comments
 
LVL 1

Expert Comment

by:busbus
ID: 21881106
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
 

Author Comment

by:Camnoc
ID: 21881474
My java script knowledge is very limited, how do I add to function
0
 
LVL 1

Expert Comment

by:busbus
ID: 21881734
<HTML>
 <HEAD>
 </HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
      put here the function
//-->
</SCRIPT>
 <BODY>
 </BODY>
</HTML>
0
 

Author Comment

by:Camnoc
ID: 21881897
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 1

Accepted Solution

by:
busbus earned 500 total points
ID: 21881937
<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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 21881975
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
 

Author Closing Comment

by:Camnoc
ID: 31470975
Thank you
Works like a dream

Paul
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 21882012
???
0
 

Author Comment

by:Camnoc
ID: 21885257
Thank you My company only uses IE but worth knowing

Paul
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now