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 24116
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
Expert Mod 4TB
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
Expert Mod 4TB
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
Expert Mod 4TB
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 onreadystatechange-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...
|
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...
|
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...
|
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...
|
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
-------------...
|
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...
|
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...
|
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...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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,...
| |