?
Solved

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

Posted on 2008-06-26
9
Medium Priority
?
734 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

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…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…
Suggested Courses

765 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