Solved

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

Posted on 2008-06-26
9
726 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

785 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