Hi,
I have a dynamic country and region list i am trying to get working but for some reason when i select a country the next region field does not populate.
Here is the code: HTML -
<select name="country" onchange="update(this.value)"> <option value="184">USA</option>
-
<option value="183">United Kingdom</option>
-
</select>
-
-
<select name="region" onchange="alert(this.value)">
-
<option value="">Make a selection </option>
-
</select>
-
-
Javascript -
-
var AdminResponse = "";
-
-
function parseResponse(){
-
-
var nText = AdminResponse.getElementsByTagName('optionText');
-
var nVal = AdminResponse.getElementsByTagName('optionVal');
-
document.forms[0]['region'].options.length = 1;
-
for (i=0; i<nText.length; i++)
-
{
-
var nOption = document.createElement('option');
-
var isText = document.createTextNode(nText[i].firstChild.data);
-
nOption.setAttribute('value',nVal[i].firstChild.data);
-
nOption.appendChild(isText);
-
document.forms[0]['region'].appendChild(nOption);
-
}
-
}
-
-
function update(nVal){
-
-
var AdminRequest = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
-
AdminRequest.onreadystatechange = function()
-
{
-
if (AdminRequest.readyState == 4)
-
{
-
if (AdminRequest.status == 200)
-
{
-
AdminResponse = AdminRequest.responseXML;
-
parseResponse();
-
}
-
else {
-
alert('Error Update.php File '+ AdminRequest.statusText);
-
}
-
}
-
}
-
var infoStr = "?choice="+nVal;
-
AdminRequest.open("GET", "Update.php"+infoStr, true);
-
AdminRequest.send(null);
-
}
-
-
PHP
[PHP]
<?php
$choice = $_GET['choice'];
$xml = "<?xml version='1.0' ?><options>";
require_once('i nit.php');
$query = "SELECT * FROM regions WHERE countryid = '$choice'";
$result = @mysql_query($q uery);
$num = @mysql_num_rows ($result);
if ($result && $num > 0)
{
while ($row = mysql_fetch_arr ay($result,MYSQ L_ASSOC))
{
$xml .= "<optionTex t>" . $row['region'] . "</optionText><opt ionVal>" . $row['region'] . "</optionVal>";
}
}
$xml .= "</options>";
@mysql_free_res ult($result);
@mysql_close();
header("Content-Type: text/xml");
echo $xml;
?>
[/PHP] SQL Structure
id / countryid / region
1 / 184 / Brighton
2 / 184 / Berkshire
3/ 184 / Bath Avon
4 / 184 / Bedfordshire
5 / 183 / Alabama
6 / 183 / Alaska
7 / 183 / American Samoa
8 / 183 / Arizona
Any help would be greatfully appreciated.
Cheers,
Adam
13 1336 acoder 16,027
Recognized Expert Moderator MVP
Hi Adam, welcome to TSDN!
Check the responseXML object. Does it have the data you expect?
Thank you.
How would i go about checking this?
acoder 16,027
Recognized Expert Moderator MVP
I have just ran Firebug on the page when i select a country and it shows me the following error:
document.forms[0].region has no properties
[Break on this error] document.forms[0]['region'].options.length = 1;
Any Ideas?
Cheers,
Adam
acoder 16,027
Recognized Expert Moderator MVP
That should be document.forms[0].elements['region'].options.
Hi,
Now i am getting the following error:
document.forms[0].elements.regio n has no properties
[Break on this error] document.forms[0].elements['region'].options.length = 1;
Cheers,
Adam
acoder 16,027
Recognized Expert Moderator MVP
Is this the only or first form on the page?
Yes there is 2 other forms on the page. I have just removed these and it works fine.
How can i get this to work with the other forms?
acoder 16,027
Recognized Expert Moderator MVP
Instead of forms[0], use forms[formName] to target the particular form.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Nathan Bloomfield |
last post by:
Does anyone know if there is any documentation which relates to Access2k + ?
or can anyone help adjust the code?
I am having trouble converting the DAO references.
TITLE :INF: How to Create a Dynamic Crosstab Report
PRODUCT :Microsoft Access
PROD/VER:1.00 1.10
OPER/SYS:WINDOWS
|
by: Amp Inthalangsy |
last post by:
Hi there,
Was hoping someone would have an fix for me or some kind or work around. I
was able to get my client side dynamic dependent list box working but if
my child list data has double quotes or hard breaks as values it wont work
at all and I am getting a "underterminated string constant" error.
If anyone can help please email me at: ainthalangsy@pembinatrails.ca
thanks in andvance
|
by: serge |
last post by:
How can I run a single SP by asking multiple sales question either
by using the logical operator AND for all the questions; or using
the logical operator OR for all the questions. So it's always
either AND or OR but never mixed together.
We can use Northwind database for my question, it is very similar
to the structure of the problem on the database I am working on.
IF(SELECT OBJECT_ID('REPORT')) IS NOT NULL
DROP TABLE REPORT_SELECTION
|
by: npverni |
last post by:
I have a fairly complex form that needs to load and maintain the state
of several different dynamic user controls. Here is the workflow:
1) A series of editable user controls (each containing basic web form
elements: textboxs, buttons, etc) are loaded from an xml file.
2) The user can either edit these user controls or select from a list
of user controls to add to teh page.
3) The user clicks "save" to save the content of all of...
|
by: phcmi |
last post by:
I have a PropertyGrid question. My task is to replace a legacy dialog
box presentation with a modern one. The dialog itself allows the user
to set configuration settings in our application, so it
seems to me that a PropertyGrid is a perfect modern replacement. I won't
bore you with the details with all the controls on the dialog since I'm
only concerned with one issue. The legacy dialog contains a drop down
list control that is...
| |
by: mtsylvester |
last post by:
Hi All,
How do I add a List Box to a dynamic Details View. I want to replace
the check boxes with list boxes. If I try to simply replace the check
box with a list box it complains about not being able to convert it to
a datacontrol field. Below is a portion of my current code behind. By
the way I tried doing dynamic templates and was not able to get it to
work. Please help, this is driving me nuts.
Thanks
|
by: mix01 |
last post by:
Hi,
I am trying to get some VBA code working, but am preplex as to why it does not work. I would really appreciate any level of help.
Many thanks,
Mix01
Version of the program
|
by: MaryamSh |
last post by:
Hi,
I am creating a Dynamic Search in my application.
I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove)
By pressing Add button ,another row will be created with the same control (I mean another dropdown and 2 button) and so on.
and by pressing Remove button the selecetd row will be removed.
I used viewstate to keep my value for postback,
I want by changing selectedvalue of...
|
by: MaryamSh |
last post by:
Create Dynamic Dropdownlist Controls and related event
--------------------------------------------------------------------------------
Hi,
I am creating a Dynamic Search in my application.
I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove)
By pressing Add button ,another row will be created with the same control (I mean another dropdown and 2 button) and so on.
and by...
|
by: sirsnorklingtayo |
last post by:
hi guys please help about Linked List,
I'm having trouble freeing the allocated memory of a single linked list node with a dynamic char* fields, it doesn't freed up if I use the FREE() function in C.. But if I try to use a single linked list with a static char array fields I can free the memory allocated with out any problems using the FREE(). So, why freeing a single linked list with dynamic char* is hard and why the FREE() function is...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |