This is mostly taken from bits and pieces found on the internet and I need help adjusting it, because I don't understand how it works. I have a form that will display selects based on a select, and this works great. I now want the second select to show <Input Type="text" Name="txtOtherAsset"> only when "other...please specify" is selected, and of course hide it when it's not. Thanks for your help.
My current working functions: -
function showCustomer(str){
-
xmlhttp=GetXmlHttpObject();
-
if (xmlhttp==null){
-
alert ("Your browser does not support AJAX!");
-
return;
-
}
-
-
var url="getclient.asp";
-
url=url+"?q="+str;
-
url=url+"&sid="+Math.random();
-
-
xmlhttp.onreadystatechange=stateChanged;
-
xmlhttp.open("GET",url,true);
-
xmlhttp.send(null);
-
}
-
-
function stateChanged(){
-
if (xmlhttp.readyState==4){
-
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
-
}
-
}
-
-
function GetXmlHttpObject(){
-
if (window.XMLHttpRequest) {
-
// code for IE7+, Firefox, Chrome, Opera, Safari
-
return new XMLHttpRequest();
-
}
-
if (window.ActiveXObject){
-
// code for IE6, IE5
-
return new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
return null;
-
}
-
-
function showAsset(str){
-
xmlhttpAsset=GetXmlHttpObjectAsset();
-
if (xmlhttpAsset==null){
-
alert ("Your browser does not support AJAX!");
-
return;
-
}
-
-
var urlAsset="getasset.asp";
-
urlAsset=urlAsset+"?a="+str;
-
urlAsset=urlAsset+"&sid="+Math.random();
-
-
xmlhttpAsset.onreadystatechange=stateChangedAsset;
-
xmlhttpAsset.open("GET",urlAsset,true);
-
xmlhttpAsset.send(null);
-
}
-
-
function stateChangedAsset(){
-
if (xmlhttpAsset.readyState==4){
-
document.getElementById("txtAsset").innerHTML=xmlhttpAsset.responseText;
-
}
-
}
-
-
function GetXmlHttpObjectAsset(){
-
if (window.XMLHttpRequest) {
-
// code for IE7+, Firefox, Chrome, Opera, Safari
-
return new XMLHttpRequest();
-
}
-
if (window.ActiveXObject){
-
// code for IE6, IE5
-
return new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
return null;
-
}
-
-
function populate(form){
-
var f=form.ClientAsset;
-
var selectedOption = f.options[f.selectedIndex].value;
-
var strWrkOrdAsset = selectedOption.split(",");
-
//form.txtAssetType.value=strWrkOrdAsset [1];
-
document.getElementById("txtAssetType").innerHTML=strWrkOrdAsset [1];
-
}
-
My getAsset.asp -
<SELECT Name="ClientAsset" onChange="populate(this.form)">
-
<OPTION></OPTION>
-
<OPTION>Other...please specify</OPTION>
-
<% Do Until objRSAsset.EOF %>
-
<OPTION Value="<% Response.Write objRSAsset("AssetID") & "," & objRSAsset("Type") %>"><% Response.Write objRSAsset("Asset") %></OPTION>
-
<%
-
objRSAsset.MoveNext
-
Loop
-
%>
-
</SELECT>
-
My WorkOrder.asp -
<TD>
-
<SELECT ID="ClientCompany" Name="ClientCompany" onchange="showCustomer(this.value);showAsset(this.value)">
-
<Option>Select Client Company</Option>
-
<% Do While Not objRSCompany.EOF %>
-
<Option Value="<% Response.Write objRSCompany("ClientCompanyID") %>"><% Response.Write objRSCompany("ClientCompanyName") %></Option>
-
<%
-
objRSCompany.MoveNext
-
Loop
-
%>
-
</SELECT>
-
<%
-
objRSCompany.Close
-
Set objRSCompany = Nothing
-
%>
-
</TD>
-
<TD>Client User</TD>
-
<TD>
-
<DIV ID="txtHint">Please select Company first</DIV>
-
</TD>
-
</TR>
-
<TR>
-
<TD>Client Asset</TD>
-
<TD>
-
<DIV ID="txtAsset">Please select Company first</DIV>
-
</TD>
-
<TD>Asset Type</TD>
-
<TD>
-
<DIV ID="txtAssetType"> </DIV>
-
</TD>
-
</TR>
-
3 2575
I got this to work by running two seperate functions in the getAsset.asp onchange event, where the second function hides and unhides the text box based on what as selected.
- <form name="form1">
-
Select Subject :: <select name="subject">
-
<option value="php" onclick="hide_other()">PHP </option>
-
<option value="asp" onclick="hide_other()">ASP </option>
-
<option value="html" onclick="hide_other()">HTML </option>
-
<option value="java" onclick="hide_other()">JAVA</option>
-
<option value="other" onclick="view_other()">Other</option>
-
</select>
-
<input type="text" name="other_suject" id="other_subject" style="display:none;"/>
-
</form>
-
<script type="text/javascript">
-
function view_other()
-
{
-
document.getElementById("other_subject").style.display="block";
-
}
-
function hide_other()
-
{
-
document.getElementById("other_subject").style.display="none";
-
}
-
</script>
An onchange event on the select element makes a lot more sense here.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: j.t.w |
last post by:
Hi All.
I'm having a problem with my Date of Birth textbox. When I open the
..htm file, the "DoB" textbox is flat with a border. All of my other
textboxes are sunken and are yellow.
When I...
|
by: cmay |
last post by:
I am having a problem with the use of "this". Maybe someone can help
me out here, let me know if I am doing this wrong:
Lets say I have an object MyObject, which has local variables, and some...
|
by: vladislav.moltchanov |
last post by:
I am developing an Access tool for generating an Application MDB for
data entry in a "large scale" project. At design stage I would like to
keep open these two MDB. One current is generating forms...
|
by: Bill Cohagan |
last post by:
I'm trying out ASP.Net and am currently trying to figure out how to refresh
the contents of one frame based on a button click in another frame. The
button in question is actually a server side...
|
by: Ron L |
last post by:
I have a barcode scanner which uses a "keyboard wedge" program so that the
data it scans comes through as if it was typed on a keyboard. I am trying
to have the data in the barcode be displayed in...
|
by: SharpCoderMP |
last post by:
the Localization property of the Deployment Project allows to select one
of only few languages, that is: Chinese, English, French, German,
Italian, Japanese, Korean, Portugal, Russian, Spanish....
|
by: Truevision .Net |
last post by:
Hi,
I have a problem with drag and drop functionality when it comes to
dropping pictures from sources like for example internet explorer and
the webbrowser control. Dragging and dropping from...
|
by: Kurda Yon |
last post by:
Hi,
I found one example which defines the addition of two vectors as a
method of a class. It looks like that:
class Vector:
def __add__(self, other):
data =
for j in range(len(self.data)):...
|
by: jonceramic |
last post by:
Hi All,
My apologies for asking something that I'm sure has been answered
for. But, my google searching can't find a proper set of keywords.
I would like to add "New..." or "other..." or...
|
by: dkyadav80 |
last post by:
<html>
///
here what shoud be java script for:
->when script run then not display all input text field only display selection field.
->when user select other value for institute only this...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |