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
Share on other sites

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.