473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Ajax refresh/reload

162 100+
Im using this script, http://www.captain.at/howto-ajax-form-post-get.php, to make an ajax request to php via a drop-down (DD) select. This works fine. Then using this script, http://www.dhtmlgoodies.com/index.html?whichScript=ajax-dynamic-content, i request to show a php page with other form elements in it. These elements are determined by what the first DD of the first request (captain.at) sets a variable to. This works fine.. only the first time though. What seems to be happening is that even though each time a DD option is selected, the variable changes as it should, but when the second script fires it still shows the previous variable. Its like the div is not reloading the page with new vars set, its just showing the page it first ran. I have tried to make another call to show a different page, this works for clearing content of the div, which i want, but not making the div reload with a page using fresh vars. I hope i got my point across.

My main question i think is, how, when i call the dhtmlgoodies script, can i get the div/page to show using the newest variable? Here is some stripped out important code.

index.php
Expand|Select|Wrap|Line Numbers
  1. <select id="sale_type_id" name="sale_type_id" onmousedown="ajax_loadContent('search','ajax_search_blank.php');" onchange="makeRequest('ajax_search.php?sti=',this.value);ajax_loadContent('search','ajax_search.php');">
  2.  
  3.     <? $_stt = db_query("SELECT sale_type_id, sale_type_name FROM sale_type WHERE sale_type_id <> 43 ORDER BY sale_type_name ASC");
  4.     while($stt = db_fetch_array($_stt)) { ?>
  5.         <option value="<?php pv($stt['sale_type_id']); ?>"><?php pv($stt['sale_type_name']); ?></option>
  6.     <? } ?>
  7.  
  8. </select>
  9.  
  10. <p>
  11.  
  12. <DIV id="search"></DIV>
  13.  
ajax_search.php
Expand|Select|Wrap|Line Numbers
  1. <? 
  2. /*   set the sale_type id for the search drop down.   */
  3. if(isset($_GET['sti'])) {
  4.  
  5.     $_SESSION['sti'] = $_GET['sti'];
  6.  
  7. }elseif(isset($_SESSION['sti'])) { 
  8.  
  9.     $_stt = db_query("
  10.     Select distinct
  11.     sale_type_field.sale_type_field_name,
  12.     sale_type_field.sale_type_field_id
  13.     From
  14.     sale_type_field
  15.     JOIN connector_sale_type_field ON sale_type_field.sale_type_field_id = connector_sale_type_field.sale_type_field_id
  16.     Where
  17.     connector_sale_type_field.sale_type_id = '".$_SESSION['sti']."'
  18.     ORDER BY
  19.     sale_type_field.sale_type_field_name ASC
  20.     ");
  21.     while($stt = db_fetch_array($_stt)) {
  22.         $sale_type_field_id[] = $stt['sale_type_field_id'];
  23.         $sale_type_field_name[] = $stt['sale_type_field_name'];
  24.     } ?>
  25.  
  26.     <select name="search_field[]">
  27.         <option value=""></option>
  28.         <option value="sale_id">Sale Id</option>
  29.  
  30.         <?php for ($j = 0; $j < count($sale_type_field_name); $j++) { ?>
  31.  
  32.             <option value="<?php pv($sale_type_field_id[$j]); ?>"><?php pv($sale_type_field_name[$j]); ?></option>
  33.  
  34.         <?php } ?>
  35.  
  36.     </select>
  37.  
  38. <?php } ?>
  39.  
Feb 20 '07 #1
1 2440
acoder
16,027 Expert Mod 8TB
How about on your onchange event handler:
Expand|Select|Wrap|Line Numbers
  1. makeRequest('ajax_search.php?sti=',this.value);ajax_loadContent('search','ajax_search.php?sti=',this.value);
Feb 21 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: John Smith | last post by:
I am using Ajax to refresh a DIV area by setting the innerHTML=request.responseText in the usual manner. in the response text I have a <SCRIPT> tag in line, but this is not executed. Is there a way...
10
by: Piotr Nowak | last post by:
Hi, Say i have a server process which listens for some changes in database. When a change occurs i want to refresh my page in browser by notyfinig it. I do not want to refresh my page i.e....
10
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 -------------...
5
by: Kaante | last post by:
Hi, I basically have two frames on my page, the top one contains users stats and the bottom frame contains the website. I want to have a message icon on the top frame which would flash once the...
5
by: =?Utf-8?B?Sm9obg==?= | last post by:
Hi, I used the following code to refresh the parent page, and it works very well (Thanks to Peter Bromberg "). Response.Write("<script language='javascript' type='text/javascript'{...
1
by: christian | last post by:
Hello I use a AJAX refresh script on a page to test a $var state <div> <? include ("include/refr.inc.php"); //ajax script for reload require ("bd_inc.php"); //test the line state buzy or...
1
by: petvampire | last post by:
not sure if some one got a answer to this little issue. Im built a page that calls information from a page called database-update.asp and puts it in to the div tag Reload this. What i am trying to do...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
marktang
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,...
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.