Jump to content

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.


  •  

Edited by DrRossi
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

Edited by DrRossi

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.

Edited by DrRossi
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.