您的位置:首页 > Web前端 > JavaScript

Passing Array From Javascript To PHP in Joomla!1.5

2011-10-23 16:14 417 查看
Debug in Javascript

How to use 'Alert' :

<html>
<head>
<script type="text/javascript">
var variablename = 7;
function show_alert()
{
alert(variablename);
}
</script>
</head>
<body>

<input type="button" onclick="show_alert()" value="Show alert box" />

</body>
</html>


DIY javascript stack trace

JavaScript Trace Window

Javascript Basic

variables in Javascript

introduction to Javascript

Manipulate Form Elements with Javascript

How to create HIDDEN Input element using DOM

Thread: creating hidden field in javascript

...How to create hidden variables dynamically?

insert hidden input element to form

How can I add a hidden form field just before submitting a form using JavaScript?

Pass values to PHP

Array values from javascript to php

My Case Study: Passing Ordered Teams To Server

Step 1: Add a hidden input field to the form



Step 2: Add one Javascript function that populates all the teams id, and concatenate them, put it into this hidden input value



Step 3: Call this Javascript function before submit



Step 4: Receive the hidden input at server end with PHP



Do a testing at this point:

please note the order before clicking 'save':



and what does PHP receive?



the order is saved!!

Step 5: Explode the string into array of ids



The array becomes an array of integers now!!

REFS:
http://www.hscripts.com/tutorials/php/jsArrayToPHP.php http://hk.php.net/manual/en/function.array-shift.php http://php.net/manual/en/function.explode.php
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐