Convertir un tableau javascript en php
majoras62
-
Rente Posted messages 138 Status Member -
Rente Posted messages 138 Status Member -
Hello, I wanted to implement drag&drop on my PHP page, it works great. For reference I’m using Toolman’s script. From there I created a function that displays the content of my left list. I’d like to know if it’s possible to pass from a JavaScript function that returns the content of a JavaScript array to a PHP array.
Thank you very much
Thank you very much
Configuration: Windows XP Internet Explorer 6.0
4 answers
-
It’s hard to say without knowing more precisely what you want to do. Maybe it should be done differently. Anyway, here’s the brute-force method I have in mind: transform the array into a string, then split it in PHP: js:
new_tab_js = tableau_js.join(";");php:$tab_php = explode(";", $tab_js)on the other hand, we agree that transferring from JS to PHP implies changing page (or reloading), so sending the JS array via POST or GET... js:document.location.href = 'newpage.php?tab_js='+new_tab_js;
-
Hello pkjmr I used your three lines of code and everything works. Thank you for the advice. Maybe I can ask you for additional assistance, still on the same subject. I actually want to send to the server, specifically to the page newpage.php, data coming from the HTML code of my form and data created and managed only by my JavaScript script. I now have, via the HTML FORM+ACTION duo, the ability to send the data in the HTML part of my page to the server and, with the code document.location.href = 'newpage.php?tab_js='+new_tab_js;, the ability to send to the server the data coming from JavaScript. But how can I send simultaneously both types of data.
- The method would be to create a hidden input that does not yet contain the value to transmit:
<input id="un_id" type="hidden" name="new_tab_js" />
then on the form submission button you add an onclick event that calls the function that will set the correct value and then submit the form:
<input type="button" value="valider" onclick="document.getElementById('un_id').value=new_tab_js; form.submit();" />
thus the string will be transmitted with all the other form data (not visible in the address bar)
-
-
Hello, thank you for showing interest in my problem, I will try what you recommended. I know it may sound a bit far-fetched, but can we solve this problem together on MSN, so I can better develop and attach the source files.
majoras62@hotmail.com -
-
Um, I’m bringing up the topic again...
Where are you at?
I want to do exactly the same, but I’m struggling a bit (a lot actually...)