Solved

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

Posted on 2008-06-26
9
730 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

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
 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Session on Html 8 42
how can i break an array into a couple 5 26
Boolean 13 26
Scroll 5 news at a time using vticker 2 12
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

730 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