I am making a print function for printing a list within a div. When the print button is clicked, the data in the inputs for the list is placed a new input that will be printed. I have been asked to remove blank inputs and have the filled ones appear together. I have been told to use a while iteration, but I don't even know how to go about doing that.
My inputs that send the data to be printed are the printArea_# and placed in the printLoad_#
I was given this code, but don't know how to use it...
$('#mydiv').children('input [type=text]').each(function () {
alert(this.value); // "this" is the current element in the loop
});
This is my working print function, it places the data into the new input for printing, but still displays the empty data as well, ( I am sure there is a much cleaner way to do this too.)
function print_list() {
$('input[id=printLoad_1]').val($('input[class=printArea_1]').val());
$('input[id=printLoad_2]').val($('input[class=printArea_2]').val());
$('input[id=printLoad_3]').val($('input[class=printArea_3]').val());
$('input[id=printLoad_4]').val($('input[class=printArea_4]').val());
$('input[id=printLoad_5]').val($('input[class=printArea_5]').val());
$('input[id=printLoad_6]').val($('input[class=printArea_6]').val());
$('input[id=printLoad_7]').val($('input[class=printArea_7]').val());
$('input[id=printLoad_8]').val($('input[class=printArea_8]').val());
$('input[id=printLoad_9]').val($('input[class=printArea_9]').val());
$(".printing_list").printElement(
{
overrideElementCSS:[
'/css/print_fixer.css',
{ href:'/css/print_fixer.css',media:'print'}],
//leaveOpen:true,
//printMode:'popup',
});
}
I want to hide unfilled table rows until data has been placed into one of the inputs. Here is an example of one of my table rows.
<tr id="num_1">
<td><input id="printLoad_1" type="text" style="width:700px;" /></td>
</tr>