php question: multiple forms

php question: multiple forms

by Yew Hong Ng -
Number of replies: 2

I searched through some googled sites without any definitive answer for this. I was trying to create some links using the delete.gif and edit.gif icons, which will pass several variables to another page. But it looked really unsightly with the many variables appearing on the url, so I thought why not create forms instead of links, with input type="image". So I created separate forms for the different icons (there are several edit and several delete icons on 1 page), with different values of the variables being passed through input type="hidden". But i found that regardless of with icon i click on, the variables sent is always the last one declared? It's as if all the different values of the variables were sent, and the last value of a certain variable simply overwrites the earlier values. Any idea on this?

Also, is it considered a taboo to use javascript in moodle codes?

Average of ratings: -
In reply to Yew Hong Ng

Re: php question: multiple forms

by Yu Zhang -
Hmm are they all named the same? Would be easier to tell if you copy and paste some code here =)

And no, there's tons of javascript used in moodle!
In reply to Yew Hong Ng

Re: php question: multiple forms

by Chris Jeffries -

There is a PHP behaviour when recovering form data that might explain this.

If you have multiple fields with the same name, then when inside a php script you try to recover the form value, you only get the last. If you include [] at the end of the variable name, PHP will know to expect more than one and will pass all of them back as an array. Check for details on the php documentation site www.php.net here http://uk2.php.net/manual/en/faq.html.php

I don't know for certain this is your problem, but the symptoms do sound like it.