Jump to content

DarkSnake747

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.evileyegames.com

Profile Information

  • Gender
    Male

DarkSnake747's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. No problem. Glad I could help... in some way I guess. If you want, you could check out my site and keep in contact. I often like helping people with programming and javascript is one language I am pretty good with. I just can help more if the question is directed to me. evileyegames.com - we have a programming help forum to... so, maybe useful for you.
  2. While we could discuss the topic - POST via AJAX - I don't think that is the problem. First, I assume the "league array" is set prior to the code you've shared... otherwise... this would really be bombing. You're dynamic radios should be fine with the onclick event as is. That said, what is actually happening with this code that makes you think there is a problem? Is the AJAX always giving you the last selected team's point values only?? The reason that would be is that the SESSION is not persistent over an AJAX call. So if your AJAX handling script - "zz_get_test_points.php" - doesn't start out with a session_start() call or some inclusion of a session ini script from a framework you may have in place, then the session is not usable in the sense you would want it to be. In other words, $_SESSION['total_points'] would always be uninitialized when you were using it and would be initialized by the current selected team's points ONLY. The tally process wouldn't work. If that is the issue... there is another. You can have n teams and n leagues... but you can only pick 1 team per league... but you only have 1 session var to hold the total. So... if you have... L1 - T1: 10pts, T2: 15pts, T3: 5pts L2 - T1: 0pts, T2: 10pts, T3: 15pts L3 - T1: 20pts, T2: 10pts, T3: 5pts we may pick: L1T2, L2T3, L3T2 which would give us 15+15+10 = 40pts total... now what happens if I change my L1 selection to say T1 instead of T2? Total points SHOULD say 35pts... but with the logic you are trying to implement, at best, this would no tell you the total is 50pts. There is no "substraction" of points... or handle on each teams points. Is it possible to eliminate AJAX here though? Just store the points as the teams values on the radio buttons. Or do you need those radios to have the id as the value for form submission beyond the process you are sharing here? In either case, you may want to just do the tally on return or in a session based array (again considering that you would have to start your session on the AJAX handling php script). Here's a description on those to resolutions... take your pick. 1 - on return of values... Just return the point value from the ajax and insert it into a hidden form element (you would create 1 hidden container per league, something like <input type="hidden" id="league<?php echo $leagueid; ?>" value="" />). Then on return from the AJAX, takes its returned content and just say document.getElementById('league' + needAnotherParamForLeagueId).value = returnedValue; then automatically trigger a function that would tally all the values of all the hidden league fields. Now... for the easier method... 2 - session based array In your main page where the form is printed out, create this... $_SESSION['leaguepoints'] = array(); Then as you loop through the leagues and print the radios, take the league id and make a new element in this array with it as the key... $_SESSION['leaguepoints'][$league_row['ID']] = 0; Then in your AJAX handling script - zz_get_test_points.php - you would simply update the appropriate array element AND loop through the array tallying the values.... ... $_SESSION['leaguepoints'][$teamsLeague] = $points; ... $totalpoints = 0; foreach ($_SESSION['leaguepoints'] as $league=>$points) { $totalpoints += $points; } echo $points; // or print or whatever you want to do to return the value. Hope that helps. If you ever need help and want me to take a look, I have a direct help forum that I just open on my site for people to get programming help directly from me. My credentials are posted there to. http://www.evileyegames.com
  3. Well, I can see 2 areas of possible problems. The least likely of the two is with the with the request URL, you may want to URL encode that (though now that I think about the values and the string you're sending, I am not sure it would do anything). URL encoding in JavaScript is broken into detail here - http://www.javascripter.net/faq/escape.htm - however, this is probably not the problem. Have you checked the return value in some dev tools? Cause that would be a great way to see if the problem is server-side, or client side, or with the initial post I suppose. I am figuring its server-side with the page you are posting to. Can you give me a link to this page on the web? And more importantly, can you post the code on the file you are requesting with AJAX? The "handling" code that would build your return.
  4. Not sure how to report this, but I have run into this and fixed the issue in projects in the past, but right now, at the very least, Chrome users with XHTML validator installed are counting as 2 views per each view because of the validation bot. Was a pain for me to realize, but now that I do... I have elements in place to prevent it. Mods/Staff... let me know if you are interested in resolving this matter and need any assistance.
  5. On my site, I have 1 or 2 areas on the page at a time that displays some list of people. To ensure code is not duplicated, I have a php script that dynamically builds the JavaScript needed for each page that uses control flags to prevent the same js code from being added more than 1 time. The syntax of the JS is correct. That said, here's what happens... Click on a member name and a loading pane appears and then the request is made. The onreadystatechange is set inline to a function that takes the returned data and displays it in place of the loading bar. It is really quite simple... however, Google Chrome doesn't finish the process. It seems (after placing an alert in the onreadystatechange function) that the ready state is not changing... or at least it is not triggering the event. It doesn't work randomly on several pages, and other pages it never works - all in Chrome. IE and FF handle it fine. If you want to see it in action, go to evileyegames.com, create an account, and go to the Friends and Foes pages... then the sub page for "Others" (people you are neither friend nor foe with). Click a name and check it out. I used dev tools to monitor it. The readystate does change... according the tool, but the function is never triggered. As for success or not on the request, reviewing the resources in the dev tools shows the request and the completely correct response. :-\ so confused... Any ideas? Help?
×
×
  • Create New...

Important Information

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.