Jump to content

[SOLVED] Help with while loop


Ninjakreborn

Recommended Posts

Basically count is the number of row's we need total.  Temp is suppose to be so it can stop when it get's to the count.

What is wrong with this while loop.

I have tried it and it throws the browser into a seeming endless loop, then asks if I want to kill the script because it's going to make ie lockup?

Any advice on this one?

function product_add() {

// get values from form
var product_name =  $('#productcodes').attr('value');	
var count = {{$count}}
var temp = 1;
// get random character to use as id, until we get data from the db.
var randomnumber = Math.floor(Math.random()*70);

// create new row in the table
$('#blank_row').before( $('#blank_row').clone().attr('id', 'user'+randomnumber).show() );// clone blank row before blank row

// replace all the names of the new row, with the new one
$('#user' + randomnumber + ' .blank_name').attr('id','user_name_'+randomnumber).click(editField);

while (temp < count) {
	$('#user' + randomnumber + ' .blank_' + temp).attr('id', 'user_value' + temp + '_' + randomnumber).click(editField);
	temp = temp++;
}
$('#user' + randomnumber + ' .blank_rec').attr('id', 'user_rec_'+randomnumber).click(editField);

// fill in the html data with the related data.
$('#user_name_' + randomnumber).html(product_name);
$('#user_value1_' + randomnumber).html('30');
$('#user_value2_' + randomnumber).html('30');
$('#user_value3_' + randomnumber).html('30');
$('#user_value4_' + randomnumber).html('30');
$('#user_value5_' + randomnumber).html('30');
$('#user_value6_' + randomnumber).html('30');
$('#user_value7_' + randomnumber).html('30');
$('#user_value8_' + randomnumber).html('30');
$('#user_value9_' + randomnumber).html('30');
$('#user_value10_' + randomnumber).html('30');
$('#user_value11_' + randomnumber).html('30');
$('#user_value12_' + randomnumber).html('30');
$('#user_rec_' + randomnumber).html('yes');
$('#user_rec_' + randomnumber).after('<td><a href="#" onclick="product_delete(' + randomnumber + '); return false;">Delete</a></td>');
// remove data from form after everything else is done, so a new one can be added
}

Link to comment
https://forums.phpfreaks.com/topic/86197-solved-help-with-while-loop/
Share on other sites

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.