PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hey,
I have a pretty simple question but I'm having a hard time finding a workabout/solution on the net. I'm new at this so I don't know all the tricks and turns. What I'm trying to accomplish is:
Take the value of the desired shipping selected and onchange, add that value (either 7$ or 15$) to the total. Thanks
Here is the code
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
1) upon submiting, the option value ("7" Shipping Local) always reset to default.
2) how can it be done on the fly (upon selecting and not having to click the submit button).
php runs server-side. The client has to perform a new http request to pass data to a php script. E.g. you can use the onchange event handler to submit the form.
You can add the attribute selected="selected" of an option element to make it the default selection.
danedner wrote:2) how can it be done on the fly (upon selecting and not having to click the submit button).
Use Javascript, not PHP to do it. As volka said, what you are asking should be done on the client. Though there is nothing wrong with pushing it to the server, and you should probably put that in just in case the user has Javascript disabled.