Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
converting JS array to a php array
Old 01-22-2007, 07:40 AM converting JS array to a php array
numbenator's Avatar
Webmaster Talker

Posts: 516
Location: London
Trades: 0
Hi


I have a js array which when form submitted i wish to
convert into a form array (php) that can be porcessed to the database.


How do i do this

cheers
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
 
Register now for full access!
Old 01-23-2007, 05:59 AM Re: converting JS array to a php array
Skilled Talker

Posts: 96
Name: Tudor Barbu
Trades: 0
You can try this reading this article in my blog, about how to send a javascript array to PHP.
__________________

Please login or register to view this content. Registration is FREE
Tudor.b is offline
Reply With Quote
View Public Profile Visit Tudor.b's homepage!
 
Old 01-23-2007, 11:14 AM Re: converting JS array to a php array
numbenator's Avatar
Webmaster Talker

Posts: 516
Location: London
Trades: 0
OK well im trying to use it with out much joy at all.

my form is called "revisions"
array I wish to write to is myArray
and js array is called form_links

<input type="submit" name="submit" value="Save Changes" onclick="convertJsArrayToPhpArray(form_links, 'myArray' , 'revisions')"/>


To check this i am simply echo myArray[0]

NO joy.

Any ideas?
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
Old 01-23-2007, 11:40 AM Re: converting JS array to a php array
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
Code:
<script type="text/javascript">
<!--
function jaArray() {
     
     output = '';
     for(i = 0; i < form_links.length; i++) {
       output = output + '<input type="hidden" name="myArray[]" value="' + form_links[i] + '" />';
     }
     
     document.getElementById("jsForm").innerHTML = output;
     return true;
     
}
-->
</script>
 
 
...
 
 
<!-- Your form goes here //-->
<input type="submit" name="submit" value="Save Changes" onclick="jaArray();"/>
<div id="jsForm"></div>
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 01-23-2007, 12:46 PM Re: converting JS array to a php array
Skilled Talker

Posts: 96
Name: Tudor Barbu
Trades: 0
numbenator: try it like this:
HTML Code:
<form action="foo" method="post" onsubmit="convertJsArrayToPhpArray(form_links, 'myArray' , 'revisions')" id="revisions">
<input type="submit" "Click me" />
</form>
and in your PHP

PHP Code:
print_r$_POST['myArray'] ); 
__________________

Please login or register to view this content. Registration is FREE
Tudor.b is offline
Reply With Quote
View Public Profile Visit Tudor.b's homepage!
 
Reply     « Reply to converting JS array to a php array
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14830 seconds with 12 queries