Welcome Guest, Not a member yet? Register   Sign In
Get the value of a radio input before that submit the form.
#1

[eluser]masentinel900[/eluser]
Hello everyone.
Right now I need to get the value of a radio input before of submit the form.

I'm generating a dynamic tables with data from a DB with CI, I'm adding it in the web page with AJAX and javascript without frameworks. All ok. But my question start on . How can I get the select value of a radio input?.

This is for may to have the hand of each one of the rows the dynamic table.
#2

[eluser]PhilTem[/eluser]
Use JavaScript/jQuery

Code:
<$cript>
var $value = $('#id-of-radio-button').val();
</$script>

of course, replace the $ with an s and add appropriate markup before assigning the value.
#3

[eluser]masentinel900[/eluser]
What do you think that will be the better event handler for may to work in this?
#4

[eluser]masentinel900[/eluser]
I was thinking in some like:

Code:
var z = document.getElementById('gen');
var y = document.getElementById('edit-res-content');
var x = document.getElementById('eject-edit-res');
if(x.onclick && z.select(value == 1))
{
  alert(y.value);
}

Is for get the value of the radio input, if their value is == 1 so coming with next steps. But Dont' works because I don't know how put that two conditions ..
#5

[eluser]PhilTem[/eluser]
This should actually help you and work for you as long as you adopt the markup (i.e. the IDs to match the IDs of your items you want to work on)

https://gist.github.com/4319986

If you need something else, at least for me you'd need to rephrase your question since I don't see if you want to manipulate the form before submitting or when selecting something on the radio buttons and then append another select depending on the value of the radio-item selected.




Theme © iAndrew 2016 - Forum software by © MyBB