Skip to content
Advertisement

Getting radio button value and sending through ajax to php

I have a poll on my website which displays radio buttons next to each answer. When the user selects an option and submits, im running a a php script via ajax to insert the value or the selected radio button into a table.

My Ajax is running but is currently inserting a 0 row each row, so it’s not picking up the value from the radio button. Any help would be appreciated.

HTML:

JavaScript

AJAX:

JavaScript

PHP: (shortened version)

JavaScript

Thanks in advance!

Advertisement

Answer

JavaScript

You should then have the POST variable “poll_option” accessible in your PHP script.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement