Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript array displaying all values

Hello People here is my code,

function send()
{
  var param_count=document.getElementsByName('eqt_param[]');

  for (var i=0; i<param_count.length; i++)
  {
    var test=param_count[i].value;  
    var param_value='Eqt_Param'+i+'='+test;

    alert(param_value);
  }
}

if i alert i get "Eqt_Param0=4.00" then "Eqt_Param1=3.00" but i want to alert at once output should be something like "Eqt_Param0=4.00,Eqt_Param1=3.00 " after alerting this way i also want to remove the ',' in between how to fix this?

like image 803
Friend Avatar asked Apr 22 '26 22:04

Friend


1 Answers

Do you mean this:

function send()
{
  var param_count=document.getElementsByName('eqt_param[]');
  var values = [];
  for (var i=0; i<param_count.length; i++)
  {
    values.push('Eqt_Param'+i+'='+param_count[i].value)
  }
  alert(values.join(', '));
}
like image 72
Akhil Sekharan Avatar answered Apr 24 '26 10:04

Akhil Sekharan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!