I'm having trouble with a three-dimensional $_POST array. It starts as a two-dimensional array on this side:
Code: <html>
<head>
<title>test</title>
<script type="text/javascript">
var Dom = {
get: function(el) {
if (typeof el === 'string') {
return document.getElementById(el);
} else {
return el;
}
},
add: function(el, dest) {
var el = this.get(el);
var dest = this.get(dest);
dest.appendChild(el);
},
remove: function(el) {
// var el = this.get(el);
// el.parentNode.removeChild(el);
}
};
var Event = {
add: function() {
if (window.addEventListener) {
return function(el, type, fn) {
Dom.get(el).addEventListener(type, fn, false);
};
} else if (window.attachEvent) {
return function(el, type, fn) {
var f = function() {
fn.call(Dom.get(el), window.event);
};
Dom.get(el).attachEvent('on' + type, f);
};
}
}()
};
Event.add(window, 'load', function() {
var i = 2;
Event.add('add-element', 'click', function() {
var el = document.createElement('span');
el.innerHTML = '<input type="text" name="theArray['+i+']['name']" value="">';
i++;
Dom.add(el, 'content');
Event.add(el, 'click', function(e) {
Dom.remove(this);
});
});
});
</script>
</head>
<body>
<p id="add-element">Add Elements</p>
<form action="testPost.php" name="test" method="post">
<input type="text" name="theArray[1]['name']" value="foo" />
<input type="text" name="theArray[2]['name']" value="bar" />
<div id="content"></div>
<input type="submit" name="submit" value="submit" />
</form>
</body>
</html>
(If you're wondering why I only have one element it's because this is for a project where I will need nested lists later.)
Now, onto testPost.php to process the code:
Code: <html>
<head>
<title>asdfdf</title>
</head>
<body>
<ul>
<?php
for ($i=1;$i<=count($_POST["theArray"]);$i++){
echo("<li>".$_POST['theArray'][$i]['name']."</li>");
}
?>
</ul>
</body>
</html>
$_POST itself is an array, so we convert from a two-dimensional to a three-dimensional array. For some reason, only the first letter gets printed; the rest of the string gets truncated.
My only request is that you don't suggest I just use a database or something of the like. This has to be easily portable and I will probably merge this into one document later.
Thank you
User registration and login
I don't know whether this is the correct forum, if not i apologise but am pretty desperate at the moment.I have a phpbb3 forum and have a custom registration form. the password is hashed usering the
Parse error: parse error in C:wampwwwlogspagesmembers.php on line 16
I dont see the problem with this, I always get Parse error: parse error in C:\wamp\www\logs\pages\members.php on line 16, what did I do wrong?? <?php $sql = "SELECT *
Click counter to ignore traffic from search bots
I have a click counter on my site that...well, counts the number of clicks a link gets on the frontpage. It's a good system, but it's got a few flaws, an example being that it counts
cURL error
So here is my code... I got it off of here... http://www.youtube.com/watch?v=XcgQUsorF_8Because I'm completely new to cURL, just wanna get a page that requires a login... I wrote everything word for
How to get exact 3 moths post date from today date using javascript
How to get exact 3 moths post date from today date using javascriptPlease help
Greek characters in php
Hi,I'm making a script and I m using for first time greek characters.I started to write a simple drop down menu that loads some city names from the database. The names are in Greek in the database and
search query in mysql in php problem
my search query wont work, i know, that my codes are correct.please helpCode: [Select]<table width="300" border="0" align="center" cellpadding="0"
Php navigation
I have four buttons on a php page.If i click a button it will redirect to different php pages.How would i do that with php?
rand() function
just a general question guys a girls, is the rand() function 100% random or is it based on time?
need help in update query
i create a form for update. there are 8 columns in my mysql table. on my main page all the data is retrieve from db and displayed on the page. after every row there is a link edit. when user click