Ajax :: How To Update Multiple DIVs Accordingly

Oct 18, 2009

I am creating a form. The form uses variable to show different divs. Like for example .
If the user chooses state where tax will be implemented than it will update the div which contain total amount. Now the problem is I have 3 divs on a page and I want to update all of them accordingly. Like user select quantity as 500, state as florida. So I need to update 3 divs .. total cost, Shipping cost and quantity divs. Problem is they all r not inside a single div else I would have put tht whole div inside the response. So is there a way to update multiple divs?

Below id the ajax code I am using ..
Code:
function update_dockcontent() {
var quantityval = document.HVAC_Cards_Form.Quantity.value;
var BillingZip = document.HVAC_Cards_Form.BillingZip.value;
var url = '[URL]'+quantityval+'&BillingZip='+BillingZip;
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
if (req.overrideMimeType) {
req.overrideMimeType('text/xml');
} .....

Code for ajaxcall page is:
Code:
<?
header("Cache-Control: no-cache");
header("Pragma: no-cache");
$total=($_GET[qval]*0.50);
$shippingrate="50";
if($_GET[BillingZip]) {
$total=$total+$shippingrate;
}?>
<p>Total Quantity: <strong><?=$_GET[qval]?></strong></p>
<p>Shipping: <strong><?=$shippingrate?></strong></p>
<p>Total cost: <strong>$<?=number_format($total,2)?></strong></p>
I want to show all 3 of them in different divs.

View 3 Replies


ADVERTISEMENT

Updating Multiple DIVs With Ajax?

May 10, 2011

I've created an ajax function which retrieves comments from a news article. But if I am logged in I will also have access to an input field for posting comments. The problem / question is that if I use Ajax I can only update one div with the responseText? How would I go about updating another one where I want to insert my form field. Can I make multiple requests in some certain manner or do I simply create another ajax function updating it separately?

http.onreadystatechange = function(){
if(http.readyState == 4){
document.getElementById(newsId).innerHTML = http.responseText;
}}
http.open("GET", "AjaxController.php?func=newsGetComments&showcomments="+newsId, true)
http.send();

View 3 Replies View Related

AJAX :: Update Multiple Window Elements With Single Request?

Dec 18, 2010

The general outline is that I have part of a page that deals with the addition, editing and deletion of upcoming events. Data is stored in a MySQL table. The form design (in traditional terms) would be very simple requiring three fields, one for the Event Name, one for the Event Description and one (hidden) to identify the UniqueID of the event in the MySQL table. (As the reference to make edits.) The table therefore has 3 fields. (There are more such as Timestamp, clientID etc, but they are not important here.)

I envisage three functions, one to add, one to edit and one to delete the event listed on the page. I have 3 php files eventadd.php, eventedit.php and eventdelete.php which speak for themselves.However, this is where I have the problem. What I have been doing is returning the xmlhttpresponse as a formatted HTML page for the two 'form' elements because whilst I can return unformatted text containing the relevant fields in one response, I don't know how to break that down into two sections for the innerHTML of the two 'form' elements that change.

Returning a formatted page does work, but as well as being slower than neccessary, I am also running into character-set encoding issues and I just know that I am not doing this properly. I can supply code and things, but I have a feeling that this problem will have come up somewhere and probably has a recognized solution because to me it seems to be such an obvious requirement to be able to populate several form elements with fields from one recordset.

View 4 Replies View Related

JQuery :: Load Content From Multiple Txt Files Into Divs Using Ajax?

Jun 8, 2011

This is my current script

<script type="text/javascript">
$(document).ready(function(){
$("div.content1").load("content_1.txt");
$("div.content2").load("content_2.txt");

[Code].....

What I'm trying to do is get the script to look for class names div.content"x" and then correctly load content_"x".txt

View 4 Replies View Related

JQuery :: Hover And Multiple Divs - All Hidden Divs Are Shown, Not Just The One That Supposed To?

Oct 14, 2010

I have been trying to do some tooltips for a website and desperately wanted to learn something new and do that with jQuery.However, every time a mouse hovers over a tooltip, all hidden divs are shown, not just the one that supposed to. Here's my html:

Code HTML4Strict:
<div class="tip">
<a href="#"></a>[code].....

View 2 Replies View Related

JQuery :: Update Several Divs Within A .each() Loop?

Jul 22, 2009

I want to update the contents of several divs periodically with the response i get from a php-script. the number of divs is changing depending on what the user has chosen before. i store the variable part of the ids in a hidden input field. this input field may look like this:

<input type="hidden" name="devices" value="1,2,3,4,5,6,7">
to do this task periodically i use setIntervall():
<script type="text/javascript">
// dies stellt sicher, dass updateDivs() erst ausgeführt wird, wenn

[Code]....

View 1 Replies View Related

Multiple Selects To Update The Price?

Apr 19, 2010

I am building a system for creating a booklet.I want the user to be able to select the quantity of booklets they require. (eg 50, 75, 100, 125)Then also select the number of pages each booklet will require. (eg. 4, 8, 12)

both will be select drop down boxes.I would like the price to be calculated based on the selections and displayed on the page.It will be total price not price per booklet.This is how i have built up the prices in php.

if($b_maxpages == '4' && $b_quantity == '50') { $amount = "95.00"; }
elseif($b_maxpages == '4' && $b_quantity == '75') { $amount = "103.00"; }
elseif($b_maxpages == '4' && $b_quantity == '100') { $amount = "115.00"; }

[code]....

I will also need the selected data to be posted once the form is submitted.

View 1 Replies View Related

JQuery :: Update Multiple Div Tags Predators

Nov 9, 2011

I have a webpage that contains a ton of php code. Every so often I need a jquery to update a few areas of the page. I can make a separate jquery for each div tag but it would be a lot simpler if I could update each using the same jquery. This is my code for updating div tag predators.....
<!-- Only updates single div tag. look into updating multiple div tags in same jquery-->
<script src="[URL]"></script>
<script>
$(document).ready(function() {
$("#predators").load("predators.php");
var refreshId = setInterval(function() {
$("#predators").load('predators.php?randval='+ Math.random());
}, 9000);
$.ajaxSetup({ cache: false });
});
</script>
The big question is; is it possible?

View 3 Replies View Related

Update 'total' Field With Multiple Price Fields?

Nov 11, 2010

i am currently developing a cart for a website at my company.What i am attempting to do is update the grand total field dynamically as the product total (determined by quantity & price) are being populated.Each product in the cart is being generated by a foreach (php) reading from a mysql database.As the total values are not being prepopulated im not exactly sure what the logic would be to get the desired values.

I will also mention im relatively new to the whole web development area, i started begining of this year and feel i could still learn alot about the 'logic' of a computer.If anything is unclear about what i stated above feel free to request additional information.

View 2 Replies View Related

JQuery :: Update Multiple SPAN Elements On My Page Using The $.get Function

Feb 14, 2011

I am fairly new with jQuery and am trying to figure something out. I am trying to update multiple SPAN elements on my page using the $.get function. So far this is the code I have...

I can loop through and verify it is catching all of them

This outputs the data I am expecting from the GET

How can I set the data returned to the innerHTML of the current span element in the loop?

I have tried $(this).innerHTML and this.innerHTML, but neither worked

View 6 Replies View Related

Only In IE, Prototype's Element.update() Doesn't Work Multiple Times

Sep 17, 2009

The following code works find in firefox and chrome. In IE, it only works the first time I click on a link.

// I have some div's where help is, which I make non-viewable
<div id='help_guides'>
<div id='issue1'>Help with issue 1</div>

[code]....

View 1 Replies View Related

Displaying The Multiple Divs?

Dec 21, 2009

I have a form with 3 questions and 9 hidden option divs. Questions are answered in radio form and it will be mandatory to answer each question. Depending on which radio in each question is selected, several of the hidden divs will display, once the "Get options" button is selected. Now the code I have already works fine (only tested in IE8), however I'm almost 100% positive that the Options() function can be truncated considerably. In the final form, there will be 36 individual permutations of radios and as you can see with the little example below, the function will get quite large.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

[code]....

View 2 Replies View Related

Replace Of Div With Multiple Divs?

Aug 10, 2011

I have a fixed size area.called a container tag.And based on selection of no of divs the area should divide into those many no of equal divs.And is there any other techinic to divide area by multiple divs or parts.

View 1 Replies View Related

Color Multiple Divs With Same Id?

Feb 4, 2011

In short, I have a lot of divs with the same id and would like to change the background color without having to name them all differently. Is there anyway to do it?

Using:
Code:
document.getElementById(timebox).style.backgroundColor = #E00;

But that only changes one div.

View 4 Replies View Related

Possible To Show Multiple Divs?

Oct 5, 2010

I was wondering how to show MULTIPLE divs.

Not one at a time, but all my divs with one link.

Is this possible?

View 2 Replies View Related

AJAX Update Page

Oct 6, 2006

I followed the video tutorials on this site - pretty good. I'm now able to delete records and remove the tr on he fly. Im also able to insert a new record i my db, i the background. But how do i update my page so the post shows up? Code:

View 2 Replies View Related

JQuery :: Multiple Divs With Same Effect?

Jan 26, 2011

On my site I have a news page, where users can read part of the news (trimmed with php) and then they click "Read more" to see the full news item. That item then comes up in a popup (using jQuery of course) and should be displayed. To get this to work I'm usingthisby including it like so:

<script type="text/javascript" src="includes/jquery.colorbox.js"></script>

The jQuery code looks like so:

$('.open').colorbox({width:"50%", inline:true, href:"#news"});

This all works great with that one div. The problem is, my news will be coming from a MySQL-query via PHP in a while-loop and I need this effect applied to every single news item. What I tried is to do this:

while($row = mysql_fetch_assoc($rs)) {
echo '<a class="open" href="#">Read more</a>';
echo '<div id="wrapper" style="display:none">';

[code]....

how do I make this work? How do I make jQuery open only the news item I'm clicking on? I know it could possibly be done with (this) and maybe children() or something like that? But I'm totaly lost at the momeny, I've tried loads of stuff with the pieces mentioned above but can't get it to work and most times I just "break" the jQuery and the popup won't even come up at all.

View 4 Replies View Related

JQuery :: Multiple Divs Using Same Class?

Apr 28, 2011

I have a div with a height of 100 pixels.If the content is too much to fit in div, I want to show a 'Read More' link at the bottom.If you then click 'Read More', the div expands to full height so all the content can be seen and the link text changes to 'Read Less'.If you then click 'Read Less', the div contracts back to 100 pixels.I've found solutions that can handle the above situation, but I want to have multiple divs with the same class that all work independantly of each other.So I'd have the following HTML

[code]
<div class="openclose">
...some content...

[code]....

View 3 Replies View Related

JQuery :: Multiple SlideToggle Divs?

Aug 20, 2010

I'm trying to piece together a little div which slides out and shows various links to sites like Digg, Reddit to share the story with. I've got it kind of working but when there are multiple divs on the page, named the same like in each article of a post on a Wordpress blog. Only the top ones work and the rest don't do anything...I'm trying to get it do something like the image => HereThis is an example I'm trying to get to work but the second "slickbox" div never shows

View 1 Replies View Related

JQuery :: NextUntil Over Multiple DIVS?

Jan 31, 2011

I'm trying to use nextUntil to select all the .cell divs between the .start-date and .end-date, the code works for the .cell's within it's .cal-container but if wont work over multiple .cal-containers.The code I have is$('.start-date').nextUntil('.end-date').addClass('fill-date');

<div class="cal-container">
<div class="cell" id="1" title="01-01-2011">1</div>
<div class="cell" id="2" title="02-01-2011">2</div>

[code]....

View 2 Replies View Related

Swapping Multiple Divs Onclick?

Jan 26, 2011

Want to swap multiple divs using onclick. Understanding of js is cursory. The way its set up now is when you click it hides a pre-specified div-this causes issues because you dont know which div the user is going to be on and if the user is on a different div then one specified it hides random divs. I want to hide the 'active' div. Heres the code. In head:

Code:
<script type="text/javascript" language="JavaScript"><!--
function HideDIV(d) { document.getElementById(d).style.display = "none"; }
function DisplayDIV(d) { document.getElementById(d).style.display = "block"; }
//--></script>

[Code]...

View 5 Replies View Related

Select Show Multiple Divs?

Apr 8, 2010

I am trying when a user chooses an airline from dropdown seen here [URL].. that two additional drop downs appear for departing airport and arrival airport. I have coded it to work when one chooses American Airlines from drop down, but I need different departing and arrival airports to appear for the various a user may choose.

View 5 Replies View Related

Showing Multiple Divs From Selectbox

Mar 29, 2011

im not so good in javascript.I want to show multiple divs on select of a <option> box. So lets say there are 3 options.All works fine up to some point, when I choose lets say option 'b' first.. I get 2 divs. Thats good.. Then I choose option 'c' I get only one div. Thats good.But if I choose option 'b' again, I get 3 divs instead of 2 !! It shoudnt show the div from from option 'c'.

View 1 Replies View Related

One Function To Toggle Multiple Divs?

Mar 30, 2011

I will have a page with about a 100 or so different links and I would like each one to toggle the visibility of its corresponding hidden div.For instance, if I have a county 'Johnson' when it's clicked I would like the hidden div associated with that county to become visible. I would like to do this without having to write a different function for each one. Is there a way to do this easily?

Below is a solution I was given elsewhere but I couldn't get it to work.Most ideal of all I would like it to work with an image map, with each county having it's own set of stats to be toggled in.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>[code].....

View 9 Replies View Related

Print Multiple Nested Divs?

Aug 24, 2010

I have multiple divs something like this

<div id="div1">
<div id="div2">
<div id="div3">

[code]...

I want JavaScript code to print div1 with all nested divs as well I tried using the following code but it only print div1 content

PHP Code:

var printContent = document.getElementById('div1');
var windowUrl = 'about:blank';
var uniqueName = new Date();

[code]...

View 1 Replies View Related

Fading Multiple In And Out Divs On Click

Aug 8, 2007

What i would like to achieve is a single page with multiple fade in/fade out divs.
Like this section of the Apple site, click the navigation on the left, the different content sections fade in/out, the links are all hash links to id'd divs on the page. so the whole thing doesn't fall apart without the script.

I did a bit of a trawl and found this example that works on the mouseover, I had a look as the script and can't see how I would change it from 'hover' to 'click'.
The other I found was this one But the 'multiple' example on there seams to have some sort of 'flicker' and the examples all use script within the href which isn't great accessibility wise.

I also took a look at the Apple page, they are using 'scriptaculous' to do this, but they also do a bunch of other things on that page so finding the bit that just does the click fading, is a bit like a needle in a haystack.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved