Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7531815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:16:28+00:00 2026-05-30T05:16:28+00:00

this is the JS <SCRIPT type=text/javascript> $(function() { var ids = new Array(); for(var

  • 0

this is the JS

    <SCRIPT type="text/javascript">
    $(function() 
    {   

        var ids = new Array();

        for(var i = 0; i < <?php  echo $numR; ?>; i++)
        {
            ids.push(i);
        }

        function f(place) {
           $("#prod_btn" + place).click(function () {

                var combine = "prod_title" + place;
                var userNameVal = $("#" + combine).val();
                var radVal = $('input:radio[name=prod_rad' + place +']:checked').val();
                $.post( 
                 "cart.php",
                 { uval : userNameVal,
                    rval : radVal },
                 function(data) {
                    $('#show_search2').html(data);
                 }

              );


           });
        }

        for (var i=0; i<ids.length; i++) 
        {

           f(ids[i]);
        }

    });
</SCRIPT>

this is the HTML

while ($i < $numR)
{
$prod_image_id = 'prod_image'.$i.'';
$prod_title_id = 'prod_title'.$i.'';
$prod_priceM_id = 'prod_priceM'.$i.'';
$prod_priceA_id = 'prod_priceA'.$i.'';
$prod_priceH_id = 'prod_priceH'.$i.'';
$prod_priceP_id = 'prod_priceP'.$i.'';
$prod_rad_id = 'prod_rad'.$i.'';
$prod_btn_id = 'prod_btn'.$i.'';

$prodID         = mysql_result($result, $i, "astm_product_ID");
$prodName       = mysql_result($result, $i, "astm_product_name");
$prodPic        = mysql_result($result, $i, "astm_product_image");

$mPrice         = mysql_result($result, $i, "astm_mill_finish_price");
$aPrice         = mysql_result($result, $i, "astm_anodised_price");
$hPrice         = mysql_result($result, $i, "astm_hanolok_price");
$pPrice         = mysql_result($result, $i, "astm_powdercoat_price");

    echo "<li>";
    echo "<DIV id='prod_container'>";
    echo "<DIV id = 'fp1'><center><IMG class = 'imagesize' src='images/fp1.png' id = '$prod_image_id'/></center></DIV>";
    echo "<DIV><p>$prodName<p><input type = 'hidden' id = '$prod_title_id' value = '$prodName' /></DIV>";
    echo "<DIV><input type='radio' value='$mPrice' name='$prod_rad_id'>Mill Finish - Php $mPrice</input></DIV>";
    echo "<DIV><input type='radio' value='$aPrice' name='$prod_rad_id'>Anodised - Php $aPrice</input></DIV>";
    echo "<DIV><input type='radio' value='$hPrice' name='$prod_rad_id'>Hanolok - Php $hPrice</DIV>";
    echo "<DIV><input type='radio' value='$pPrice' name='$prod_rad_id'>Powder Coat - Php $pPrice</input></DIV>";
    echo "<DIV><button type='button' id = '$prod_btn_id' onClick = 'fg_popup_form(\"fg_formContainer\",\"fg_form_InnerContainer\",\"fg_backgroundpopup\");'>Add to Cart</button></DIV>";
    echo "</DIV>";
    echo "</li>";

$i++;
}

The js simply gets the value of the radio button selected and the name of the product. It works fine. My problem is that I also want to get the text of the selected radio button. “.text()” is not working for me and I don’t know why. Help Me Thanks! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T05:16:29+00:00Added an answer on May 30, 2026 at 5:16 am

    Using a form to access the selected radio button

    tl;dr here is a live demo: http://jsfiddle.net/g105b/wchyLcfc/

    A really nice trick is how browsers expose the selected radio button of a form, by its name.

    Consider this HTML, with a gender choice:

    <form id="myForm">
        <label>
            <input type="radio" name="gender" value="m" />
            <span>Male</span>
        </label>
    
        <label>
            <input type="radio" name="gender" value="f" />
            <span>Female</span>
        </label>
    
        <label>
            <input type="radio" name="gender" value="o" />
            <span>Other</span>
        </label>
    </form>
    

    Because the form has an ID of myForm, in JavaScript you can access the currently selected radio button like this:

    var myForm = document.getElementById("myForm");
    var selectedRadio = myForm["gender"];
    

    and from this, you can get the value of the radio box, or the text content of the containing label:

    selectedRadio.value // m, f or o
    selectedRadio.parentElement.textContent // Male, Female or Other
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Look this code: <script type = text/javascript> function mouseClick (container) { container.appendChild (document.createTextNode (Can
look at this code, <head> <meta http-equiv=Content-Type content=text/html; charset=utf-8 /> <script> function change() {
I have a page as below: <head> <script type="text/javascript" src="jquery-1.6.1.js"></script> <script type="text/javascript"> $(document).ready( function()
HTML: <script src=http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js type=text/javascript></script> <script src=/js/grabber.js type=text/javascript></script> <script type=text/javascript> $(document).ready(function() { $('#search-js').submit(function() { var
I was wondering if anyone here had some experience writing this type of script
I got this script called rapidshare link checker v2 php by Bigfish At the
Ok, I've got this function: /* jsHandler.js */ function inc(filename) { var body =
I have this function which is imported directly in the HTML function include(filename){ var
<!DOCTYPE html> <html> <head> <meta http-equiv=Content-Type content=text/html; charset=UTF-8 /> <script src=https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js></script> <script type=text/javascript> $(
For this script, it checks to see if the file is a microsoft words

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.