I am still improving my AJAX and I ran into something that I'm not sure
how to do.
I will have a page called where I will have a dropdown list at the top
and a large display at the bottom. The display depends upon what is
currently selected in the dropdown. This is readily done via AJAX which
is activated with an onchange in the dropdown list. The contents of the
bottom half of the page are created in the php script which is sent back
to the response handler which changed the bottom part via an innerHTML.
So far OK. What I would also like to happen is that when the page is
called initially, that the bottom half shows for the first entry of the
dropdown list. I don't want to repeat code in two places.
One solution I have is to have the entire selection and bottom building
part be an include file that I put into both my AJAX server php script
and into this display page. I would just use different values for the
selected item. It would be on the display page as a require_once before
I do any html display.
My question is whether there is some better way. 8 1480
On Jun 3, 11:45*am, sheldonlg <sheldonlgwrote :
I am still improving my AJAX and I ran into something that I'm not sure
how to do.
I will have a page called where I will have a dropdown list at the top
and a large display at the bottom. *The display depends upon what is
currently selected in the dropdown. *This is readily done via AJAX which
is activated with an onchange in the dropdown list. *The contents of the
bottom half of the page are created in the php script which is sent back
to the response handler which changed the bottom part via an innerHTML.
So far OK. *What I would also like to happen is that when the page is
called initially, that the bottom half shows for the first entry of the
dropdown list. *I don't want to repeat code in two places.
One solution I have is to have the entire selection and bottom building
part be an include file that I put into both my AJAX server php script
and into this display page. *I would just use different values for the
selected item. *It would be on the display page as a require_once before
I do any html display.
My question is whether there is some better way.
Is the dropdown list dynamic or static?
If it is static and you are using a GET method (which seems logical, I
don't believe you are manipulating any data, merely retrieving it)
then why not just initiate the page using your script passing it the
desired value?
after9 wrote:
On Jun 3, 11:45 am, sheldonlg <sheldonlgwrote :
>I am still improving my AJAX and I ran into something that I'm not sure how to do.
I will have a page called where I will have a dropdown list at the top and a large display at the bottom. The display depends upon what is currently selected in the dropdown. This is readily done via AJAX which is activated with an onchange in the dropdown list. The contents of the bottom half of the page are created in the php script which is sent back to the response handler which changed the bottom part via an innerHTML.
So far OK. What I would also like to happen is that when the page is called initially, that the bottom half shows for the first entry of the dropdown list. I don't want to repeat code in two places.
One solution I have is to have the entire selection and bottom building part be an include file that I put into both my AJAX server php script and into this display page. I would just use different values for the selected item. It would be on the display page as a require_once before I do any html display.
My question is whether there is some better way.
Is the dropdown list dynamic or static?
If it is static and you are using a GET method (which seems logical, I
don't believe you are manipulating any data, merely retrieving it)
then why not just initiate the page using your script passing it the
desired value?
It is dynamic. Once in the page, a list is build from the category
passed in. It is that list that is then used to display what is in the
bottom of the page. The first llist is a db call. The second list is
also a db call using the value from the first list. Coming into the
page, we have no idea as to what the id will be for the first member on
the first list.
The more I think of it, the more the require_once of the building code
looks like the way to go. There is no duplication of code (one include
file) and it is just exercised in two different places.
On Jun 3, 12:31*pm, sheldonlg <sheldonlgwrote :
after9 wrote:
On Jun 3, 11:45 am, sheldonlg <sheldonlgwrote :
I am still improving my AJAX and I ran into something that I'm not sure
how to do.
I will have a page called where I will have a dropdown list at the top
and a large display at the bottom. *The display depends upon what is
currently selected in the dropdown. *This is readily done via AJAX which
is activated with an onchange in the dropdown list. *The contents of the
bottom half of the page are created in the php script which is sent back
to the response handler which changed the bottom part via an innerHTML.
So far OK. *What I would also like to happen is that when the page is
called initially, that the bottom half shows for the first entry of the
dropdown list. *I don't want to repeat code in two places.
One solution I have is to have the entire selection and bottom building
part be an include file that I put into both my AJAX server php script
and into this display page. *I would just use different values for the
selected item. *It would be on the display page as a require_once before
I do any html display.
My question is whether there is some better way.
Is the dropdown list dynamic or static?
If it is static and you are using a GET method (which seems logical, I
don't *believe you are manipulating any data, merely retrieving it)
then why not just initiate the page using your script passing it the
desired value?
It is dynamic. *Once in the page, a list is build from the category
passed in. *It is that list that is then used to display what is in the
bottom of the page. *The first llist is a db call. *The second list is
also a db call using the value from the first list. *Coming into the
page, we have no idea as to what the id will be for the first member on
the first list.
The more I think of it, the more the require_once of the building code
looks like the way to go. *There is no duplication of code (one include
file) and it is just exercised in two different places.
So let me get the workflow straight.
1. A user selects a category.
2. This category is passed to the display page.
3. On display page, a dropdown list is populated via a database query
of category that was passed.
4. On a dropdown change event a request is passed to a php script.
5. The php script returns database information to display page.
When #3 happens you want the display section to automatically load the
information of the first dropdown option of the category.
One solution involves the steps prior to #3. Along with passing the
category, why not pass along the first item in category's database?
Then you could have a GET request of something like display.php?
category=foo&fi rst=bar. In the display page you could check if
$_GET["first"] is set and then handle it appropriately.
On Jun 3, 12:31*pm, sheldonlg <sheldonlgwrote :
after9 wrote:
On Jun 3, 11:45 am, sheldonlg <sheldonlgwrote :
I am still improving my AJAX and I ran into something that I'm not sure
how to do.
I will have a page called where I will have a dropdown list at the top
and a large display at the bottom. *The display depends upon what is
currently selected in the dropdown. *This is readily done via AJAX which
is activated with an onchange in the dropdown list. *The contents of the
bottom half of the page are created in the php script which is sent back
to the response handler which changed the bottom part via an innerHTML.
So far OK. *What I would also like to happen is that when the page is
called initially, that the bottom half shows for the first entry of the
dropdown list. *I don't want to repeat code in two places.
One solution I have is to have the entire selection and bottom building
part be an include file that I put into both my AJAX server php script
and into this display page. *I would just use different values for the
selected item. *It would be on the display page as a require_once before
I do any html display.
My question is whether there is some better way.
Is the dropdown list dynamic or static?
If it is static and you are using a GET method (which seems logical, I
don't *believe you are manipulating any data, merely retrieving it)
then why not just initiate the page using your script passing it the
desired value?
It is dynamic. *Once in the page, a list is build from the category
passed in. *It is that list that is then used to display what is in the
bottom of the page. *The first llist is a db call. *The second list is
also a db call using the value from the first list. *Coming into the
page, we have no idea as to what the id will be for the first member on
the first list.
The more I think of it, the more the require_once of the building code
looks like the way to go. *There is no duplication of code (one include
file) and it is just exercised in two different places.- Hide quoted text -
- Show quoted text -
In the code that populates your dropdown, after populating the
dropdown simply set the selectedIndex of it to 0 and then call the
function that is called by the onchange handler, or you can even call
onchange() of the element.
function loadMyDropDown( ) {
var select = document.getEle mentById("categ ories");
//...populate the dropdown...
if (select.options .length 0) {
select.selected Index = 0;
select.onchange ();
}
}
HTH.
the bad thing about toms method is, if javascript is deactivated the
user will see nothing. I favoured your solution when I had the problem
first, for me it worked well. One tip about it: i would ad an ?ajax to
all ajax calls, e.g. includes/ajax3.php?ajax
by using if(isset($_GET['ajax'])) you can check if your file is called
by ajax or if it is included. So if you have differences in some
pathes or anything else you can avoid problems with this method
after9 wrote:
On Jun 3, 12:31 pm, sheldonlg <sheldonlgwrote :
>after9 wrote:
>>On Jun 3, 11:45 am, sheldonlg <sheldonlgwrote : I am still improving my AJAX and I ran into something that I'm not sure how to do. I will have a page called where I will have a dropdown list at the top and a large display at the bottom. The display depends upon what is currently selected in the dropdown. This is readily done via AJAX which is activated with an onchange in the dropdown list. The contents of the bottom half of the page are created in the php script which is sent back to the response handler which changed the bottom part via an innerHTML. So far OK. What I would also like to happen is that when the page is called initially, that the bottom half shows for the first entry of the dropdown list. I don't want to repeat code in two places. One solution I have is to have the entire selection and bottom building part be an include file that I put into both my AJAX server php script and into this display page. I would just use different values for the selected item. It would be on the display page as a require_once before I do any html display. My question is whether there is some better way. Is the dropdown list dynamic or static? If it is static and you are using a GET method (which seems logical, I don't believe you are manipulating any data, merely retrieving it) then why not just initiate the page using your script passing it the desired value?
It is dynamic. Once in the page, a list is build from the category passed in. It is that list that is then used to display what is in the bottom of the page. The first llist is a db call. The second list is also a db call using the value from the first list. Coming into the page, we have no idea as to what the id will be for the first member on the first list.
The more I think of it, the more the require_once of the building code looks like the way to go. There is no duplication of code (one include file) and it is just exercised in two different places.
So let me get the workflow straight.
1. A user selects a category.
2. This category is passed to the display page.
3. On display page, a dropdown list is populated via a database query
of category that was passed.
4. On a dropdown change event a request is passed to a php script.
5. The php script returns database information to display page.
When #3 happens you want the display section to automatically load the
information of the first dropdown option of the category.
One solution involves the steps prior to #3. Along with passing the
category, why not pass along the first item in category's database?
Then you could have a GET request of something like display.php?
category=foo&fi rst=bar. In the display page you could check if
$_GET["first"] is set and then handle it appropriately.
....because I don't KNOW the first item before getting to the page and
running the first db query to populate the list of items. The items are
identified by an ID which is obtained from the db based up the category ID.
Tom Cole wrote:
On Jun 3, 12:31 pm, sheldonlg <sheldonlgwrote :
>after9 wrote:
>>On Jun 3, 11:45 am, sheldonlg <sheldonlgwrote : I am still improving my AJAX and I ran into something that I'm not sure how to do. I will have a page called where I will have a dropdown list at the top and a large display at the bottom. The display depends upon what is currently selected in the dropdown. This is readily done via AJAX which is activated with an onchange in the dropdown list. The contents of the bottom half of the page are created in the php script which is sent back to the response handler which changed the bottom part via an innerHTML. So far OK. What I would also like to happen is that when the page is called initially, that the bottom half shows for the first entry of the dropdown list. I don't want to repeat code in two places. One solution I have is to have the entire selection and bottom building part be an include file that I put into both my AJAX server php script and into this display page. I would just use different values for the selected item. It would be on the display page as a require_once before I do any html display. My question is whether there is some better way. Is the dropdown list dynamic or static? If it is static and you are using a GET method (which seems logical, I don't believe you are manipulating any data, merely retrieving it) then why not just initiate the page using your script passing it the desired value?
It is dynamic. Once in the page, a list is build from the category passed in. It is that list that is then used to display what is in the bottom of the page. The first llist is a db call. The second list is also a db call using the value from the first list. Coming into the page, we have no idea as to what the id will be for the first member on the first list.
The more I think of it, the more the require_once of the building code looks like the way to go. There is no duplication of code (one include file) and it is just exercised in two different places.- Hide quoted text -
- Show quoted text -
In the code that populates your dropdown, after populating the
dropdown simply set the selectedIndex of it to 0 and then call the
function that is called by the onchange handler, or you can even call
onchange() of the element.
That is essentially to the way I now handle it. I took the bulk of the
called function and put it in a separate php file that is included in
the called function. What is not in that include file is the grabbing
of the category ID. The category ID is obtained from a $_GET from the
AJAX call. In the display page I also include that included file, but
use as the category the first entry from the dropdown list. That way I
have no duplication of code.
>
function loadMyDropDown( ) {
var select = document.getEle mentById("categ ories");
//...populate the dropdown...
if (select.options .length 0) {
select.selected Index = 0;
select.onchange ();
}
}
HTH.
ma*********@web .de wrote:
the bad thing about toms method is, if javascript is deactivated the
user will see nothing. I favoured your solution when I had the problem
first, for me it worked well. One tip about it: i would ad an ?ajax to
all ajax calls, e.g. includes/ajax3.php?ajax
by using if(isset($_GET['ajax'])) you can check if your file is called
by ajax or if it is included. So if you have differences in some
pathes or anything else you can avoid problems with this method
Great suggestion. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: HockeyFan |
last post by:
I'd like to have an AJAX textbox that after the user fills in, will
auto-fill another textbox on the page without having a postback
occur. It doesn't have to do any filtering or any other thing like
that. I'm fairly experienced with ASP.Net, but new to AJAX. Please
help if you can. Thanx.
|
by: Peter |
last post by:
I have a button on my ASP.NET 2.0 web page labelled "Copy to
Clipboard" which must use server side code to format some data in a
specific manner and then copy it to the client clipboard so it can be
pasted into another application. Initially I planned to have the
server-side code put the data string into a cookie and then use a
client-side Javascript function referenced in the button's
OnClientClick attribute to copy the contents of the...
|
by: Cirene |
last post by:
3 quick questions...
1. Are the controls in the AJAX Futures download "beta" or the release and
stable version?
2. Also, where is the best way to learn how to implement these? (Other than
by downloading the stuff at asp.net/ajax.)
3. When will the new version of AJAX be out? Will it be included with the
Visual Studio 2008 release?
|
by: Jonathan Wood |
last post by:
Greetings,
I'd like to implement some AJAX features on an existing ASP.NET site. I have
one example of doing this but, otherwise, don't know much about it.
I have one question, though, about getting started: I notice that there are
project templates for creating AJAX this and AJAX that. I'm a little
confused about this. Am I not able to add AJAX features to an existing Web
form? Why is it necessary to select an AJAX form or whatever?
|
by: Ronald Raygun |
last post by:
I have a form, which contains a textfield for a user to enter their
username. I want to provide a button that allows the user to check to
see whether that username has already been taken up by someone else (a
bit like the functionality available when signing up for hotmail.com)
My question is:
1). How can I send the text entered in the text box to a server side PHP
script?
2). How do I receive the response (simple true or false) from...
| |
by: slebetman |
last post by:
On Jun 5, 9:36 pm, sheldonlg <sheldonlgwrote:
You can of course use closure to pass the required parameter:
var hideIt; // the variable you wish to pass
ajax.onreadystatechange = function () {
if (ajax.readyState == 4) {
if (hideIt) {// here you can use the variable..}
}
}
|
by: sheldonlg |
last post by:
I am still improving my AJAX and I ran into something that I'm not sure
how to do.
I will have a page called where I will have a dropdown list at the top
and a large display at the bottom. The display depends upon what is
currently selected in the dropdown. This is readily done via AJAX which
is activated with an onchange in the dropdown list. The contents of the
bottom half of the page are created in the php script which is sent back...
|
by: sheldonlg |
last post by:
I am looking for a clean solution to a problem that I solved in, what I
call, a "dirty" way.
Here is what I want to do. I have a dropdown list. Clicking on an item
in the dropdown list invokes an AJAX call that gets data which populates
the entire lower part of my screen. It does this with an innerHTML for
the div tag that holds all of this. This works fine.
I also have an "Edit" button that I want to show next to dropdown list,...
|
by: luigi.corrias |
last post by:
Hello everybody,
this is a very difficult question…
imagine 2 webform asp.net
A and B
B is an iframe inside A..
|
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |