Passing Array From Javascript To PHP in Joomla!1.5

85 篇文章 0 订阅
62 篇文章 0 订阅

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" οnclick="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


hidden-input


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


js-hidden


Step 3: Call this Javascript function before submit


call


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


receive-hidden




Do a testing at this point:


please note the order before clicking 'save':


before-saving


and what does PHP receive?


received-hidden


the order is saved!!


Step 5: Explode the string into array of ids


process-array


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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值