Jump to content
xisto Community
Sign in to follow this  
sonesay

Ajax question

Recommended Posts

I have a general question about how ajax updates div's. Have you ever wanted to update a element inside a <div> but not nesseary update the whole div? here is an example

echo "<div id='heading_general'>";echo "<h4>General <span id='general_total'>0</span> <button id='btn_general' onclick=\"tv('general_merits','btn_general');\">-</button></h4>";echo "</div>";

like if I tried updating the span id of 'general_total' it will work but the output will be put on its own line so it messes up the format. the only other solution I have to this is updating the whoole div 'heading_general' and it will all be outputed to one line. I'm sure you can see the reason for this you will only update 1 element and not have reload all.

Notice from jlhaslip:
Split, Edited, and Moved to Programming/OtherPlease do not post into a Member's Application for Hosting Thread.Thanks.

Share this post


Link to post
Share on other sites

I can understand the reason on why you would just want to update one element, but i'm trying to figure out why it places everything on its own line. I can only come up with a few reasons:

There's a BR or P element within the new output.

There's too much text in the element.

It's a browser specific problem.

Does it meet any of these?

Share this post


Link to post
Share on other sites

The output was just an echo of "1"; I just did that to test out to change the original value of 0 to 1.I dont think it gets put on a new line because of insuficent width space. because the final output is like this.'General''1''<button>'when the original output is 'General' '1' '<button>'I tested it out on fire fox, safari and opera i believe and it does have the same effect on all 3.I am using a DTD of strict xhtml 1.0 maybe that has something to do with it. At this stage I'm happy with reloading an entire div just to keep moving forward on my project. Hopefully someone with similar issues or know a way do this method can let us know. I have posted this issue on ext forums but no response so far over there.thank you again for your response.

Share this post


Link to post
Share on other sites

Try adding this to your span tag:

<span id='general_total' style="display:inline">0</span>
(either change the quotes to single quotes or escape them out if you are going to use that echo statement)

I hope this fixes it :P

Share this post


Link to post
Share on other sites

sorry for late reply. I already went with just full div reload and I dont have my previous versions of it backed up to test out ; ; . This does look like it will work though ajax is whacked in messing up displays I remember I had similar problems in the past and putting inline styles did work to some extent. If anyone is working with sometime similar try what alex pointed out. If I do come across this bridge again i will probbaly give it another go.

heres my final merit system now http://forums.xisto.com/no_longer_exists/ I probably wont do any more work on there It was only ment to be a test for my database structure and its seems sufficent enough to support my queries so right now i'm just working on template for my site layout after that its on to bulding my linkshell management system :P.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.