Jump to content

How To Get The Value Of My Button


DrRossi

Recommended Posts

I am trying to get the radio's button value from the form to the javascript onclick function to my database.

 

I define my $output in first.php then echo it in second.php. Here is my first.php

 

 

$name = 100;

$answer = "some text";

$output .= '<div id="'.$k.'">

 

 

<form id='.$f.' >

<input type="radio" name='.$name.' value="yes" checked>Accurate

<input type="radio" name='.$name.' value="no">Not Accurate

<input type="button" id='.$j.' value="Submit" onclick="sendData(\''.$answer.'\','.$name.',)">

</form>

</div>'

 

;

$name++;

 

 

 

My jquery function in second.php

 

function sendData(feel, rID)

{

var accu = $("input[@name=rID]:checked").val();

 

$.get("test.php", { feeling: feel , accuracy: accu} );

}

 

 

 

 

When I click my button nothing is submitted. If i manually define var accu to "YES" or something it works. So the problem must be on how to check if my radio button its checked and get its value.


  •  

Link to comment
https://forums.phpfreaks.com/topic/271458-how-to-get-the-value-of-my-button/
Share on other sites

Okay found it. well I never used the console before just the html button to check the source code. Thanks for that tip.

 

When I just define the accu as a number or text or even as rID it will come up with

the "POST test.php" and the parameters etc. But when i try

$("input[name=" + rID + "]:checked");

it will not do the POST test.php

error found when I click the button

 

 

Syntax error, unrecognized expression: input[@name=510]:checked

 

throw new Error( "Syntax error, unrecognized expression: " + msg );

 

 

By the way that error won't show up in chrome's firebug, but it comes up in firefox firebug.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.