in this html the user can choose how much money he wants to contribute, but how can tell php if the user choose value 40000 for example to add this value to a variable in my script, then if the user chooses another amount add that amount to the variable?
regards
I assume by 40,000 you meant 4,000 as you don't have 40k in your code. And as a small note, you should use
Code:
checked="checked"
over just checked.
Are you sending the variables by POST or GET?
If you're sending by POST, all forum variables are stored in $_POST as an array by their name (in this case montant) and if by get, they're stored in $_GET.
hi, thanks for the checked thing, yes i am sending thru post , i still dont get how to acces the first "montant" radio , then the second etc..
im tring this :
you have to use string[] for the name to send the numbers over to php.
__________________
Official BinPress hand picked coder.
For anyone worried about SQL injection go have a look at my small yet powerful script here.
Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
I am 1 of 65,608 people to get a Pebble Watch :P
If you name your radio buttons the same ... name='montant',
only one of them can be selected at any time.
Maybe you want to use checkboxes instead?
ok thanks , now i see this is not possible with PHP , if i want to make it i need to put different names in radio buttons and mimic the multiple radio buttons behavior with javascript.right?
You basically want the "aesthetics" of the radio button (how it looks),
but not necessarily the "action" (only selecting one of several).
So you are correct ... give each button their own name and they will act separately.
It's within the PHP form processing that you will then need to deal with that.
That's why I mentioned checkboxes, because you can create an array of them.
Maybe you can use some CSS styling to change how the checkbox looks?
EDIT:
I've never tried this ... not sure what will happen ...
change
name='montant'
to
name='montant[]'
See if it treats the radio buttons as separate entities, and yet utilizing the array.
You basically want the "aesthetics" of the radio button (how it looks),
but not necessarily the "action" (only selecting one of several).
So you are correct ... give each button their own name and they will act separately.
It's within the PHP form processing that you will then need to deal with that.
That's why I mentioned checkboxes, because you can create an array of them.
Maybe you can use some CSS styling to change how the checkbox looks?
EDIT:
I've never tried this ... not sure what will happen ...
change
name='montant'
to
name='montant[]'
See if it treats the radio buttons as separate entities, and yet utilizing the array.
.
nop i need to mimic the action of radio buttons so this is why i would need JS, but i have seen this done with PHP
Frankly, don't use _REQUEST, as its notoriously insecure. If you know you're getting POST variables, only accept POST. If you're using GET, only accept GET. If someone wants an easy backdoor to your application, they'll try to get past variables like that first.
Quote:
Originally Posted by sybil6
nop i need to mimic the action of radio buttons so this is why i would need JS, but i have seen this done with PHP
PHP can't do anything HTML can't do. PHP is a server side processing language that will feed HTML to a user. There might be HTML hacks to do something like what you want, but I'd stick to JS with backup code in case someone doesn't have JS active.
I'm just confused on what you're trying to do.
You have a series of radio buttons... but you want multiple ones selected? If that's what you want, you want check boxes, not radio buttons. If you only want one selected, then you're find and want to check it with $_POST['montant'].
Keleth,
I didn't understand it either, which is why I thought maybe
the original poster wanted something to look like radio buttons,
but act like checkboxes ... that apparently isn't the case.
So, I guess we'll have to wait and see what they come up with
in regards to Javascripting ... as I don't understand.