Hi, I am trying to improve the usabilty of an app I have written and it would be great if I could refresh the content of my select boxes without refreshing the whole page.
I am sure this could be done. perhaps using iFrames. Can anyone shed some light?
9 24146
Refreshing the Select Box withut refreshing the page means in what way you want to refresh the select box. Wether are u adding the Database values into that select box or user defined values in that page should be added to the select box.
Regards
Ramanan Kalirajan
the select box is populated from my database. when I add a new item to my database i want to see the values in the select box without refreshing.
gits 5,390
Recognized Expert Moderator Expert
so you want to push an update to a webapp when your database changes without user interaction? you just need to use an ajax-call and poll the db with it ... you have to decide how often you need that and you may use setInterval() for this purpose ... you just cannot really push things to the client ... the client has to request the update ...
kind regards
Yeah i have the function of adding to my database on the same page so when I add a new item to my database I want the selectbox which is a list of records to now contain the new one. Can you show me how this is done with ajax?
gits 5,390
Recognized Expert Moderator Expert
that is not nessecary then ... you could add the option to the DB with the call and besides that you just need to add it to the node with dom-methods to avoid requests/traffic ... what have you done so far?
Its is neccessary because I have three select boxes linked together. I need to turn my requests into ajax requests. Thanks for your help anyway. Below are the unctions I am currently using to populate my select boxes - <?php
-
-
require "config.php"; // database connection details
-
echo "
-
-
function fillType(){
-
//this function is used to fill the companies in main.php on load
-
";
-
-
$q11=mysql_query("SELECT type FROM module_type");
-
echo mysql_error();
-
while($nt11=mysql_fetch_array($q11)){
-
echo "addOption(document.form1.newtype, '$nt11[type]', '$nt11[type]');";}// end of while
-
?>
-
}
-
-
function fillType2() {
-
-
removeAllOptions(document.form1.selecttype);
-
addOption(document.form1.selecttype, "", "Select", "");
-
<?php
-
$q77=mysql_query("SELECT type FROM module_type");
-
echo mysql_error();
-
while($nt77=mysql_fetch_array($q77)){
-
echo "addOption(document.form1.selecttype, '$nt77[type]', '$nt77[type]');";}// end of while
-
?>
-
}
-
-
function fillNewSub() {
-
removeAllOptions(document.form1.newsub);
-
addOption(document.form1.newsub, "", "Select", "");
-
-
<?php
-
$q22=mysql_query("select distinct(type) from subtype");
-
while($nt22=mysql_fetch_array($q22)){
-
echo "if(document.form1.newtype.value == '$nt22[type]'){";
-
$q32=mysql_query("select subtype from subtype where type='$nt22[type]' order by subtype asc");
-
while($nt32=mysql_fetch_array($q32)){
-
echo "addOption(document.form1.newsub,'$nt32[subtype]', '$nt32[subtype]');";
-
-
} // end of while loop
-
echo "}"; // end of JS if condition
-
}
-
?>
-
}
-
-
function fillselectsub(){
-
removeAllOptions(document.form1.selectsub);
-
addOption(document.form1.selectsub, "", "Select", "");
-
-
<?php
-
$q55=mysql_query("select distinct(type) from subtype");
-
while($nt55=mysql_fetch_array($q55)){
-
echo "if(document.form1.selecttype.value == '$nt55[type]'){";
-
$q56=mysql_query("select subtype from subtype where type='$nt55[type]' order by subtype asc");
-
while($nt56=mysql_fetch_array($q56)){
-
echo "addOption(document.form1.selectsub,'$nt56[subtype]', '$nt56[subtype]');";
-
-
} // end of while loop
-
echo "}"; // end of JS if condition
-
}
-
?>
-
}
-
-
function fillselectmod(){
-
removeAllOptions(document.form1.selectmod);
-
addOption(document.form1.selectmod, "", "Select", "");
-
-
<?php
-
$q44=mysql_query("select distinct(subtype) from module");
-
while($nt44=mysql_fetch_array($q44)){
-
echo "if(document.form1.selectsub.value == '$nt44[subtype]'){";
-
$q45=mysql_query("select module_name from module where subtype='$nt44[subtype]' order by module_name asc");
-
while($nt45=mysql_fetch_array($q45)){
-
echo "addOption(document.form1.selectmod,'$nt45[module_name]', '$nt45[module_name]');";
-
-
} // end of while loop
-
echo "}"; // end of JS if condition
-
}
-
?>
-
}
-
-
-
function removeAllOptions(selectbox)
-
{
-
var i;
-
for(i=selectbox.options.length-1;i>=0;i--)
-
{
-
//selectbox.options.remove(i);
-
selectbox.remove(i);
-
}
-
}
-
-
function addOption(selectbox, value, text )
-
{
-
var optn = document.createElement("OPTION");
-
optn.text = text;
-
optn.value = value;
-
-
selectbox.options.add(optn);
-
}
-
gits 5,390
Recognized Expert Moderator Expert
so you mean you have to update all three select-nodes when adding a new option to one of them? as i said ... then you need something that does the following steps:
1. user adds an option
2. start your ajax-call and insert the option to the db
3. when inserted retrieve the data from the db
4. send back the result
5. the onreadystatecha nge-handler could now update the list-nodes
ok heres what I have for the first select. I can get the values into my program but how do I put the values into the select? - function ajax_filltype(){
-
var x=0;
-
var url = "filltype.php?x=" + escape(x);
-
url = url + "&dummy=" + new Date().getTime();
-
request.open("GET", url, true);
-
request.onreadystatechange = populateselecttype;
-
request.send(null);
-
}
-
function populateselecttype() {
-
if (request.readyState == 4) {
-
var response = request.responseText;
-
var splitResult = response.split("%%");
-
for (i=0; i<splitResult.length-1; i++){
-
alert(splitResult[i]);
-
//add each option i to select box
-
}
-
}
-
-
}
php - <?php
-
-
require "config.php";
-
-
$q1=mysql_query("SELECT type FROM module_type");
-
while($r = mysql_fetch_array($q1)){
-
echo $r['type'] . '%%';
-
-
}
-
?>
never mind it was just - function populateselecttype() {
-
if (request.readyState == 4) {
-
var response = request.responseText;
-
var splitResult = response.split("%%");
-
for (i=0; i<splitResult.length-1; i++){
-
document.form1.selecttype.options[document.form1.selecttype.length] = new Option(splitResult[i], splitResult[i]);
-
}
-
}
-
-
}
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Steve |
last post by:
Hi,
I have a private website for 20 people that is similar to a web email client
like hotmail.
There are two frames, one on the left with links for "New", "History",
"Todays" and a frame on the right with a table for viewing the contents of
these messages. The left pane checks back with the server every few seconds
to see if any new messages need to be processed and updates count
accordingly.
|
by: Troy |
last post by:
Hello-
I have a website that uses a custom built webserver to serve the pages.
(Please don't ask me why my boss had his own web server written). I am
displaying a log of information that is an unknown number of rows. This is
currently displayed in a table.
The table is generated by some code that we had to write (thank you custom
webserver) so that the webserver will parse HTML files and fill in the tags
we created with some data...
|
by: paul |
last post by:
Hi All,
We have a small dilemma. We have the following page:
http://giggsey.com/m00Cow.php (don't ask about the content) that we
want to turn into an interactive application for some new intake
students at our school. However - we want to have multiple client PCs
running a web interface that will allow them to type in their name / a
message, and then this message appears on the "scroller" page, which
will be on a projector.
|
by: Assimalyst |
last post by:
Hi,
I want to create a popup to notify a user that the server side process
has completed successfully. I intended to use a javascript alert to do
this, although ideally the icon should be different, but thats another
story . . .
Anyway, on successful completion of the process i use this piece of
code:
|
by: paulie |
last post by:
Hi,
I have been experiencing an issue when trying to use AJAX to reload a DIV area
using a timer of 2000ms, which contains a html page with another DIV and javascript.
Scenario
-------------
I have perl script which simply runs a ps on a Solaris server and generates
a static html page with all of the code perfectly and this html page works fine
when viewing it statically or with a META REFRESH header tag. The idea is to give the user...
| |
by: Jimbo1 |
last post by:
Hi there,
I'm new to this group, so first of all I'd like to say a big "Hello"!
Moving on, I'm a database developer who has found himself in a grey
zone between the database and the web front end. I'm making some
enhancements to an Oracle database that's using a (now obsolete and
unsupported) utility called "WebDB" to provide a related web
application.
|
by: Peter |
last post by:
ASP.NET
I have an application which use ASP.NET Autocomplete extender which works
great. But I have a question how to update all the fields on the screen
using Ajax.
Users starts typing in a text field which causes the Autocomplete extender
to display 10 like items, after the users selects an item (which is a key in
the database) I want the application to go to the database retrieve a record
and populate the fields.
|
by: WebFoot |
last post by:
Is there a reliable way for a webpage to either
break out or refuse to display when a hostile
website puts it in a frame?
I know about the JavaScript solution, but not
all visitors have JavaScript enabled.
I also know about the target="_top" solution,
but that only works if the visitor clicks on
a link.
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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: 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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |