Jump to content

spenceddd

Members
  • Posts

    107
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

spenceddd's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi Thorpe, No I don't realy understand what it is to be honest, only that I have used it to pass an array from PHP to JS before.... Thanks TeNDoLLA I will check that link out. Spencer
  2. Do you know of any json manipulation functions that you mentioned above? Something that is equivalent to : var jsArrays = json_encode(multidimensionalArray); but that will allow me to store the multidimensional array in such a way that it can be successfully passed via post and held in a form element. Thanks Spencer
  3. OK great thanks. I will continue to look for some. Do you know of any of the top of your head? Thanks again for your help.
  4. Sorry one last thing, and I know this is specifically js but how do you format the code to put a js multidimensional array to json, is it just: var jsArrays = json_encode(multidimensionalArray); I have tried to find this online but am getting complicated possibilities and not one simple... Thanks again Spencer
  5. OK great that makes sense, now can form element hold a json value? and can a post variable hold a json value?
  6. Ah, sorry I keep replying but others keep beating me to it before I submit. Thanks for all the suggestions but djlee may have a point with posting the array, that sounds even simpler than using json....so to confirm can a post variable hold a multidimesional array?..and can a form item hold a js multidimesional array? thanks a million! Spence
  7. My issues there is that one of the table cell which is updateable is a text block where people can write comments, these comments could have any characters in which could ultimately trip it over.
  8. Hmm...I can't send to individual form items as the number is limitless and unknown. and I can't seem to interpret the string using php as the seperators for arrays are the same as seperators for array items. Also isn't there just a relatively simple way to pass arrays from js to php? Thanks for your help by the way.
  9. Yes but the form value is a js multidimensional array. Php doesn't seem to see this as anything but a very long string....
  10. Hi, I've been stuck on this for a while now and I keep coming back to it only to hit another wall. What I am trying to do is allow a user to modify a table on a page then submit the changes by refreshing the page. I have setup the javascript to allow the user to alter the values of the table cells. These values then get passed to a hidden form element that keeps track of the updated rows information in the form of a multidimensional array. This array has all the information needed to update the mysql tables if only I could pass the array back to php when the table reloads. I have had success in passing a php array to javascript using json. I have already posted a thread about this thinking that a jquery ajax function would work but I'm not sure that's necessary plus the thread was moved to the ajax forum where nobody seems to post. Could anyone please help me with this? Any help much appreciated... Spencer
  11. Just to elaborate on what I am trying to achieve here (incase I have overcomplicated it in the first place). I am updating a mysql database with information on the page which ultimiately ends up in a multidimensional js array. So when the page reloads it needs to update the mysql table before the same page then creates the table in html further down in the code. I have used JSON encode to pass info from php to js with great success but through my research I am coming up with mainly this ajax jquery function to pass from js to php via POST. Hope that makes sense. Please let me know if there is a simpler way to achieve this. Thanks for any advice here. Spencer
  12. Thanks for your help Crayon. I have tried to test your code but the php echo doesn't seem to echo. I also had to add the submit button on the page so I could trigger and test that php was picking up the array on reloading the page: <?php // check if something is posted if ($_POST) { // dump out what is posted. This is what is going to be output for the AJAX call echo "<pre>";print_r($_POST); echo "</pre>"; // exit the script so that it doesn't output the rest of the stuff in the script exit();} ?> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> <script src="jquery.js"></script> <script type="text/javascript"> var a = {}; a['test'] = 1; a['test2'] = 2; $.ajax({ url: "test.php", data: a, type: 'post', // this is your callback function success: function(data) { // update the contents of a div with the results of the ajax call $('#someDiv').html(data); } }); </script> </head> <body> <form action="test.php" method="post"> <input name="" type="submit"></form> <!-- div to update with AJAX results --> <div id='someDiv'> </div> </body> </html> Sorry if I'm missing something obvious here... Thanks again for any help on this!
  13. Hi Guys, I've been doing some research and this to be a popular way to tackle this but for some reason it's not working for me: <?php $test01=$_POST['test']; $test02=$_POST['test2']; echo($test01); ?> <html> <head> <title>Portfolio item logger</title> <script src="AC_RunActiveContent.js" language="javascript"></script> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> <script type="text/javascript"> //var existingPortfolioItems = new Array(); alert(<? $_POST['test']; ?>); var a = {}; a['test'] = 1; a['test2'] = 2; $.ajax({ url: "http://www.spencercarpenter.co.uk/portfolioAppFiles/jsArrayToPhpTest.php", data: a, type: 'post', success: function(data) { }}); </script> <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script> </head> <body> <form action="jsArrayToPhpTest.php" method="post"> <input name="" type="submit"> </form> </body> </html> If anyone could help me I would be very grateful. I think I'm missing something fundamental here... Thanks Spencer
  14. Thanks you so much maca! I haven't tried it yet but can see how it works.
  15. Thanks for your suggestion maca but I don't really understand how that works. How would I then be able to access the whole array in js? The reason I am doing this is because I want to only query the db when the page is loaded. After that I would like to be able to manipulate the data clientside with out having to go back to the server...
×
×
  • 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.