Print table - Bootstrap-vue - bootstrap-vue

How can I print a table in bootstra-vue, so that the user can print it by clicking a button?
print the entire table on a paper print
<b-table id="my-table" hover striped small outlined :items="valuesData" :fields="fields" class="mt-0 mb-0">
</b-table>

Related

How to return text to normal color after using the perl module ANSIColor?

I recently found the very fun perl module ANSIColor for changing my text color. Basically, all i need to do to change perl stdout text color is something like...
print color("red")."My sample text\n";
However, after exiting the script, my terminal is now only printing in red as well! Is there some function for return the console to the original color that I can include at the end of my script?
Thanks!
Use colored() instead of color(). This will reset the coloring after the string is printed:
print colored("My sample text\n", "red");
You can try,
print color 'reset';
Term::ANSIColor doc page says that to get back to normal text you should use reset keyword.
print color 'bold blue';
print "This text is bold blue.\n";
print color 'reset';
print "This text is normal.\n";
Also I recommend to look at Constant Interface

PERL CGI mailto does not work

I have a web report written in PERL CGI. It pulls some constantly changing data from a flat-file DB and displays the current status in a table on the web page. I want to be able to click a link that will push all of that data into an email that can be edited before sending.
This is what I have as my last chunk of HTML on the page. The "Go To Status" link works but the mailto:xxx#xx.com link causes server errors. Does "mailto" not work in a CGI script for some reason? It gets rendered as HTMl so I'm not sure why it wouldn't.
sub EndHtml {
print "<P align=right> <a href='http://www.xxx.com/~a0868183/cgi-bin/xxx.cgi'>Go to Status</a> </p>\n";
print "<p align=right> <a href='mailto:xxx#xx.com'></a>Send EOS</p>\n";
print "</BODY></HTML>\n";
}
(Once I figure this out I will then put the variables with the data into the email)
Thanks,
Jared
# has special meaning in a double quote delimited string.
Always start your script with:
use strict;
use warnings;
Then you will get alerted (if you read your log files):
Possible unintended interpolation of #xx in string
Then you can escape it:
mailto:xxx\#xx.com
Or use a single quoted string:
print q{<p align=right> <a href='mailto:xxx#xx.com'></a>Send EOS</p>\n};
Or don't embed your HTML in the middle of your Perl and use a Template language (like Template Toolkit).
You probably want to put some content in the anchor too.

Linking pages with CGI scripts

I am trying to write a survey that displays only one question at a time, each on a separate page. I cannot figure out how to have my CGI file accomplish this, right now I have everything on one page but want my user to be able to hit a "next" button to bring them to a new question. I am trying to do this with Perl and HTML exclusively. for example:
use CGI qw(:standard); # Include standard HTML and CGI functions
use CGI::Carp qw(fatalsToBrowser); # Send error messages to browser
#
# Start by printing the content-type, the title of the web page and a heading.
#
print header, start_html("Hello"), h1("Hello");
if (param()) { # If true, the form has already been filled out.
$who = param("myname");
$cats = param("cats"); # Extract the value passed from the form.
if($cats == "Y"){
print p("Hello, your name is $who, and you like cats");
}
else{
print p("Hello, your name is $who, and you don't like cats"); # Print the name.
}
}
else { # Else, first time through so present form.
print start_form();
print p("What's your name? ", textfield("myname"));
print p("Do you like cats? Y for yes and N for no", textfield("cats"));
print p(submit("Submit form"), reset("Clear form"));
print end_form();
}
print end_html;
If I want the cats question to appear on the next page, by taking out the submit button and putting in one that functions like a next, do I have to link the button to another page or can that be achieved in one script? So in short, can you create and link multiple html pages to run a survey with just one cgi script?
Sure you can. The problem is that your script needs to know which page the user has just submitted in order to know which page to show next. However, that can be achieved easily with a hidden <input> inside your <form>s. Such hidden inputs are sent by the browser to the CGI script just as if they were regular inputs, e.g. text inputs, drop-down boxes or checkboxes.
On the server side this hidden <input>s name and value are available via the normal param() method call. The hidden input itself is created with hidden(); please read the documentation available for it.

How can I get the text in the Perl/Tk Text widget?

I have written a script that gets a file name and insert the file content to a Text widget. Now when I close the script window, I need it to write the text onto the Unix screen.
How can I get the Text widget content?
My text widget insertion sorce code is:
open(FILE, $file_name);
foreach my $line (<FILE>) {
$text->insert('end', $line);
}
$text->get('1.0','end-1c');
(It's end-1c – end less one character – for fairly technical reasons; with just end you'd get an extra newline appended. A known Tk gotcha.)

How can I mark a radio button as checked using Perl?

I try to create a form that can save a person's form data so that he can later finish completing the form. I have no problem to save the data to an external file and I know that it would be easy to do what I try to do if the user was permitted to save his data only once a full page form was completed. However, I want to be able to save the data of the form at any time, even if one of multiple pages have not been fully completed. Also, I like to use my own html scripting through my Perl scripts instead of calling CGI.pm form commands.
So the user saves his incomplete data at the end of a session and log in with a password at a later time to retrieve his data. So I retrieve data from the external file based on the password using
#--------------------------------------------
open(INFO, "MYTEXTFILE.txt");
#data = <INFO>;
close(INFO);
#--------------------------------------------
foreach $key (#data)
{
($aaa1,$aaa2,$aaa3,$aaa4,$aaa5,$e)=split(/,/,$key);
}
And then I try to input the available data back into the html form. This is pretty easy when data have been collected with text-boxes:
print"
<p>Your response is: input type='text' name='aaa1' value='$aaa1' <\p>";
But more tricky when it is a radiobutton. I use:
print"
<table width='600' align='center' cellpadding='3'>
<tr bgcolor=''>
td bgcolor=''>1. Question #1
</td>
<td>1
<input name='aaa1' type='radio' value='1'"; if ($aaa1==1) {print " CHECKED ";} print"/>/td>
<td>2
<input name='aaa1' type='radio' value='2'"; if ($aaa1==2) {print " CHECKED ";} print" />/td>
<td>3
<input name='aaa1' type='radio' value='3'"; if ($aaa1==3) {print " CHECKED ";} print" />/td>
<td>4
<input name='aaa1' type='radio' value='4'"; if ($aaa1==4) {print " CHECKED ";} print" />/td>
<td>5
<input name='aaa1' type='radio' value='5'"; if ($aaa1==5) {print " CHECKED ";} print" />/td>
</tr>
</table>
";
Is there a more convenient or handy way to do it?
Yes there's an easier way.
foreach my $value (1,2,3,4,5) {
my $checked = ($aaa1 == $value) ? "CHECKED " : "";
print "<td>$value <input name='aaa1' type='radio' value='$value' $checked/></td>\n";
}
However, if you insist on hand-rolling your own templating solution (as opposed to using a great number of existing Perl templating ones), you should do it the RIGHT way. Have generic methods for various input types, etc...
Also, as others have pointed out in comments, there's a REASON for separating code from HTML via a templating solution - it greatly simplifies maintenance.
Your output contains almost the same text and code repeating 5 times. Using a for loop would be more convenient.