Ninjakreborn Posted January 15, 2008 Share Posted January 15, 2008 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 } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.