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 9118499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:10:07+00:00 2026-06-17T05:10:07+00:00

I have this code basically get some check radio of a form and then

  • 0

I have this code basically get some check radio of a form and then make send into a php file, the code its fine but im only have a doubt on the conditional part:

Html code:

<div id="content0">
<h1>Paso 1)</h1>
<p align="left"></p>
<h2>¿Cuantos procesos desea Ingresar/Consultar?</h2>
<br>
<!-- <label>Escoge un número</label> -->
<form name="form_data" id="form_data">  
    1 <input name="ciudad" value="1" type="radio">  
    2 <input name="ciudad" value="2" type="radio"> 
    3 <input name="ciudad" value="3"  type="radio"> 
    4 <input name="ciudad" value="4" type="radio"> <br>
    5 <input name="ciudad" value="5" type="radio">
    6 <input name="ciudad" value="6" type="radio">
    7 <input name="ciudad" value="7" type="radio">
    8 <input name="ciudad" value="8" type="radio"> <br>
    9 <input name="ciudad" value="9" type="radio">
    10 <input name="ciudad" value="10" type="radio"> <br>
    <input value="Enviar" id="btn_enviar0" href="javascript:toggle() </input> <br /> <br />      
    <label id=" mensaje="" type="button"> </form>
    <div id="resultado"></div>
</div>

<div id="content4" style="display:none;">
    <h1>Paso 5)</h1>
</div>

Js code:

function getRadioValue() 
{
    for (index=0; index < document.form_data.ciudad.length; index++) 
    {
        if (document.form_data.ciudad[index].checked) 
        {
            var radioValue =form_data.ciudad[index].value;
            var num2=parseInt(radioValue);
            break;
        }
    }
}

$(document).ready(function()
{
    $('#btn_enviar').click(function()
    {
        if( validaText( 'name1','Nombre' ) == false) 
            return false;
        if( validaText( 'name2','Nombre' ) == false) 
            return false;
        if( validaSelect( 'select_especialidad','Especialidad' ) == false) 
            return false;

        $.ajax({
            type:'POST',
            url :'upload4.php',
            data: $('#form_data4').serialize(),
            beforeSend : function()
            {
                $('#mensaje4').html('Enviando datos...');
            },
            success: function (data)
            {
                $('#mensaje4').html('Datos enviados correctamente.');
                $('#resultado4').html(data);    
            },
            complete: function()
            {
                $('#form_data4').slideUp();
                $('#resultado4').slideDown();
                $('#flecha4').show();
                getRadioValue();
                if (num2>=3)
                    $('#content4').show();
            }
        });
    }); 

    $('#regresar').click(function()
    {
        $('#form_data')[0].reset();
        $('#form_data').slideDown();
        $('#resultado').slideUp();
        $('#mensaje').html('');
    });
});

function validaText(texto,salida)
{
    if($('#'+texto).val()=="")
    {
        alert('Em campo '+salida+' es requerido.');
        $('#'+texto).focus();
        return false;
    }
}

function validaSelect(select,salida)
{
    if($('#'+select).val()==0)
    {
        alert('Seleccione '+salida);
        return false;
    }   
}

I don’t know much about javascript (I make my codes with php but im learning), but.. why this part of the code don’t work?

if (num2>=3)
{
    $('#content4').show();
}
  • 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-06-17T05:10:09+00:00Added an answer on June 17, 2026 at 5:10 am

    Try this

    function getRadioValue() {
            for (index=0; index < document.form_data.ciudad.length; index++) {
                if (document.form_data.ciudad[index].checked) {
                    var radioValue =form_data.ciudad[index].value;
                     return parseInt(radioValue); //<--- Change1
                }
            }
        }
    

    …

         complete: function(){
             $('#form_data4').slideUp();
             $('#resultado4').slideDown();
              $('#flecha4').show();
                var num2 = getRadioValue();  //<-- Change 2
              if (num2>=3)
    

    In your code the scope of the variable num2 is within the function getRadioValue, as you have declared in there

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a follow up from my previous question I have this code basically
I have (basically) this code - <script type=text/javascript language=javascript> $(document).ready(function() { $(#loadDiv).load(mypage.html, function(){ alert($(#someText).text())
I have this horribly stripped delphi code that basically login to server, save cookie
I have this small piece of code that basically takes a list and runs
So i have been creating this framework thing that basically puts together source code
Basically, I have somewhere in my main code where this line of code is
I have to make a program that basically reads x lines from a file
I have this code: def GetSteamAccts(): #Get list of steam logins on this computer.
I have some code below. This code is a basic push/pop stack class that
I am having some trouble with this. We basically have been asked to create

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.