For an ASp Intranet app, I have some code that should work, but I am not able
to make it happen for some reason, after spending considerable time on this.
I am pretty thick when it comes to javascript; I just don't get the syntax
at all. If
anyone could help, I would appreciate it. I'm probably pretty close. Please
note that because it's an Intranet, all users have to use IE 5 or higher.
Situation:
3 form fields on an ASP. <select> box, set of 2 radio buttons, and a text
field.
<Select> box, built by ASP from SQL Server table. One of the 7 choices in
there is the word Closed (Value of 1). When someone selects Closed, I want
a previously hidden div to appear, and it will contain 2 radio buttons (or
a <select> would be fine), with the text of (1)Final Analysis, or (2)Resolution.
Whichever a user selects of these two radio buttons will
populate the text field called BriefDesc with the phrase Final Analysis or
Resolution.
In other words, when a trouble ticket is closed, the boss wants
the tech support people to have the words Final Analysis or Resolution on
the Brief Description field, and this is a way of forcing it to happen, and
keeping it from being mispelled.
Important to note that I cann't hard-code the values of the dropdown. I wish
I could, but I have to make sure that the current value showed up as selected,
so I am using my ASP function below to do that.
Anyway, the page loads fine using the code below; I get no error messages.
But when I click the word Closed, nothing happens.
Here's what I have:
In the head section, I have
<script language="JavaScript">
//this is to make the briefdesc field do great things when the status is
changed to 'closed'
function displayRadios(menu){
if(menu[menu.selectedIndex].text=="Closed"){
document.getElementById(el).style.display="block"
}
}
</script>
Then, in the body of the page, I call an ASP function which builds the list
based on my query. Because this dropdown is showing something that already
has a value in the DB (in other words, one can change the value by using
this dropdown), I have code in there to mark the existing value (which is
in
the variable strStatusNum) as selected. First, the code on the page:
<td><span class="cellnumber">*</span><span
class="celltitle">Status:</span><br>
<select name="StatusID">
<%Set RS = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT StatusID, Description FROM TKT_STATUS "
RS.Open strSQL, objConnection
fillListBox RS,strStatusNum
%>
</select>
<div id ="foo" style="display:none">
<input name="radioclosed" type="radio" value="Resolution"
onclick="BriefDesc.value=this.value" /> Resolution
<input name="radioclosed" type="radio" value="Final Analysis"
onclick="BriefDesc.value=this.value" /> Final Analysis
</div>
</td>
<td><span class="cellnumber">*</span><span class="celltitle">Brief
Description:</span><br>
<input name="BriefDesc" style="WIDTH: 600px; HEIGHT: 22px"
maxlength=100>
</td>
Finally, the code which actually builds the dropdown, and which is located
in an include file:
Private Function fillListBox(recordSet, selected)
'Loop through the recordset and add all the options to the list.
Do Until recordSet.EOF
Response.Write "<option onchange = displayRadios(this) value=""" &
recordSet.Fields(0).Value & """"
'If a list box needs to be selected, check to see if the current value
in
the recordset loop
'is the one that needs to be selected. If so, set it to be selected.
If selected = recordSet.Fields(0).Value Then Response.Write " selected"
Response.Write ">" & recordSet(1).Value & "</option>" & vbCrLf
recordSet.MoveNext
Loop
recordset.Close
End Function 1 2917
middletree wrote:
.... note that because it's an Intranet, all users have to use IE 5 or higher.
Situation: 3 form fields on an ASP. <select> box, set of 2 radio buttons, and a text field. <Select> box, built by ASP from SQL Server table. One of the 7 choices in there is the word Closed (Value of 1). When someone selects Closed, I want a previously hidden div to appear, and it will contain 2 radio buttons (or a <select> would be fine), with the text of (1)Final Analysis, or (2)Resolution. Whichever a user selects of these two radio buttons will populate the text field called BriefDesc with the phrase Final Analysis or Resolution.
In other words, when a trouble ticket is closed, the boss wants the tech support people to have the words Final Analysis or Resolution on the Brief Description field, and this is a way of forcing it to happen, and keeping it from being mispelled.
Important to note that I cann't hard-code the values of the dropdown. I wish I could, but I have to make sure that the current value showed up as selected, so I am using my ASP function below to do that.
Can the current value be closed? Anyway, the page loads fine using the code below; I get no error messages. But when I click the word Closed, nothing happens.
Because there is no event handler assigned to the Select element to do
anything?
Here's what I have:
In the head section, I have
<script language="JavaScript"> //this is to make the briefdesc field do great things when the status is changed to 'closed' function displayRadios(menu){ if(menu[menu.selectedIndex].text=="Closed"){ document.getElementById(el).style.display="block"
and is el defined? } }
As an onChange event handler for a select element, I would suggest
function displayRadios( oSel){
var bClosed = oSel.options[oSel.selectedIndex].value == "1";
document.getElementById("foo").style.display =
bClosed ? "block" : none";
}
which allows changes to the closed status by the support agents. If you
don't want to allow them to reopen a case already closed on the DB you
need more code. AIUI the change to look up the "options" collection of
the SELECT element by selectedIndex reflects the standard way of
accessing a selected OPTION element.
</script>
Then, in the body of the page, I call an ASP function which builds the list based on my query. Because this dropdown is showing something that already has a value in the DB (in other words, one can change the value by using this dropdown), I have code in there to mark the existing value (which is in the variable strStatusNum) as selected. First, the code on the page:
.... <select name="StatusID">
needs to have an event handler, say as
<select name="StatusID" onchange="displayRadios(this)"> <%
' generate some OPTION elements in vbscript... %> </select>
<div id ="foo" style="display:none">
the display value here may need to be generated in vbscript according to
the current status on the DB - or at least determine what to do if the
case is already closed.
<input name="radioclosed" type="radio" value="Resolution" onclick="BriefDesc.value=this.value" /> Resolution <input name="radioclosed" type="radio" value="Final Analysis" onclick="BriefDesc.value=this.value" /> Final Analysis </div> </td>
again, if ops can display an existing closed case a checked attribute
may need to be placed on one of these radio buttons.
<td><span class="cellnumber">*</span><span class="celltitle">Brief Description:</span><br> <input name="BriefDesc" style="WIDTH: 600px; HEIGHT: 22px" maxlength=100>
again, this input may need a value attribute generated from current DB
values if a closed case (ticket) can be retrieved. If you prefer no
mispellings, you might like to generate the DB value on the server from
the value of the "radioclosed" radio group returned. </td>
Finally, the code which actually builds the dropdown, and which is located in an include file:
Private Function fillListBox(recordSet, selected)
'Loop through the recordset and add all the options to the list. Do Until recordSet.EOF Response.Write "<option onchange = displayRadios(this) value=""" &
Ohhhh :)
The onchange event belongs on the SELECT element and is not defined for
an OPTION element. Checkout <URL http://www.w3.org/TR/DOM-Level-2-HTML >
for attribute values which *are* defined on OPTION elements.
recordSet.Fields(0).Value & """" 'If a list box needs to be selected, check to see if the current value in the recordset loop 'is the one that needs to be selected. If so, set it to be selected. If selected = recordSet.Fields(0).Value Then Response.Write " selected"
'This doesn't do anything special with already closed cases
Response.Write ">" & recordSet(1).Value & "</option>" & vbCrLf recordSet.MoveNext Loop recordset.Close End Function
One other comment. The reason I tested equality of the .value attribute
of the OPTION element against "1", and not the .text attribute (value)
against "Closed" is that I have noted problems with IE ignoring setting
the .text value of an OPTION element. It appears to read .text
attributes okay, but I prefer to stay away from known bug areas when
possible.
HTH
cheers,
Dom This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: JL |
last post by:
Does anyone have any ideas on this please?
I don't know how to evaluate the no-blank selections against each other from
a form as follows: .
I have a form with 6 dropdown fields, each...
|
by: Wouter |
last post by:
Hi,
I would like to make a dropdown menu. When a user select something i want to
use his selection in PHP for a next dropdown menu. When the user has
selected something in the second dropdown...
|
by: anonymous |
last post by:
Hi Folks,
I have a form with two Dropdown list boxes, which get loaded with data from
Database.
DropDownList1 gets data from Table1
and
DropDownList2 gets data from Table2
Table1 has a...
|
by: Jeff |
last post by:
After I bind the repeater control in the form_load event, it builds
multiple lines based on the number of rows in the dataset.
In the repeater control, I have a textbox and a dropdown list box. ...
|
by: darrel |
last post by:
I and a coworker are building a cms via .net (vb.net)
I'm more of the front-end guy, and mainly use DW, while he's more of the
back-end guy, and uses VS.NET
He likes to use a lot of the built...
|
by: Jason Sobell |
last post by:
Hi,
I'm trying to figure out a sensible way of making a combobox (configured as
a dropdown list) behave in a read-only fashion.
Setting Enabled=False will grey the text and the background, but I...
|
by: 23s |
last post by:
I have a dropdown bound to a dataview. The binding assigns the dropdown
with a SelectedIndex of 0.
There is a msgbox in the SelectedIndexChanged event that displays the
SelectedIndex property....
|
by: er1 |
last post by:
Hi all,
I have created a double dropdown list. Based on the first list selection, second list populates (this works fine). I have a submit button, which when clicked should run a select query...
|
by: DeveloperQuest |
last post by:
How do I make Xhtml 1.0 strict or Xhtml 1.1 strict appear in the
Visual Studio 2005 dropdown?
How do I add a Xhtml 1.0 strict to the dropdown in visual studio 2005?
I have used the default...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
| |