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!
In my form, I have an onclick event that lets the user choose from different styles that are set from css classes. Each class has its own unique name. This part works great. After submit, I want to send that class name to my php script.
$_POST only contains the values of all inputs within the form which was submitted. What is the user clicking to make the selection? You can have that update a hidden field, and read that value. If there are a few buttons with the options, make the all submits with different values (hence passing on the value which was clicked)
I have 12 images each with an onclick event like above. Now as soon as I click on a thumbnail image the form submits. I have a submit button. I want the user to click the image which changes the style of the textarea. When they select the style they like and enter text in the textarea.. The text AND the style they selected has to be captured. So far it is only capturing the text.
The default style is style3. I thought this onclick event would change it to style1 but it doesn't. Not sure what to do.
You're almost there. The thing to keep in mind is that the only things in the $_POST array will be the values of each input, nothing else. So maybe something like:
I'm going with that and not the image as a submit button as IE7 took out the value assigned to image submits in the $_POST array... Seems stupid to me, but I'm sure they have their reasons. If you did want to use an image submit, rather than javascript to change the hidden field, you'll need to check the coordinates of where the user clicked the image - thats all that is now passed to $_POST with IE. I'm sure you can find that on Google quite easily