Button in html

cliftonite

Diamond Member
Jul 15, 2001
6,899
63
91
How can I capture a button click in HTML? Writing a script that by default prints the last 500 lines of a log file (this works fine). Now I need a button that will enable someone to view the next 500 lines. How can I capture this? Isnt the button syntax something like:

<INPUT TYPE='button' NAME='Next500lines' VALUE=?' So what would I change that would trigger the loop? Is there anyway to make it a boolean and check if (button) then blah blah, else blah ? Thanks for the help.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
you would use the onClick property followed by some javascript

onClick="javascript:myfunction()"
 

cliftonite

Diamond Member
Jul 15, 2001
6,899
63
91
Originally posted by: MCrusty
you would use the onClick property followed by some javascript

onClick="javascript:myfunction()"


The script is in perl. So would I have to write a javascript function to evaluate the click? And then have perl read that?
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
It sounds like you don't really care if someone clicks the button, you really want someone to submit a form.

So you want to do
<form method=post name="nextrows" action="myscript.pl">
<input type=submit value="Next Rows" name="button">
</form>

So when someone clicks on the button(submitting the form) it will perform the action specified as in, goto myscript.pl and passing the values of the form using the post method.
 

cliftonite

Diamond Member
Jul 15, 2001
6,899
63
91
Originally posted by: MCrusty
It sounds like you don't really care if someone clicks the button, you really want someone to submit a form.

So you want to do
<form method=post name="nextrows" action="myscript.pl">
<input type=submit value="Next Rows" name="button">
</form>

So when someone clicks on the button(submitting the form) it will perform the action specified as in, goto myscript.pl and passing the values of the form using the post method.

Well I dont really need a form because there is nothing to input but I just want to know when the user has hit a button, so that i can display the next 500 lines.


<p>MACID: <input type ="text" name="macid" MAXLENGTH="12"/></p>
<p><input type="submit" value="Search" /></p>
<p><input type="reset" value="Clear"/></P>


That was the form I used to get the macid. The the following code took the form input and appended it to the file format.

my $macid = $query->param('macid');

if ($macid) {
if($macid =~m/[0-9A-Fa-f]{12}/)
{
$mactxt = uc($macid).".txt";
$mtamac ="Mta" .lc($macid);
}

else {
print "Please enter a correct MAC ID", "\n";
exit;
}
}


what i need is a something like my $macid = $query->param('macid'); in perl to check if the button was pushed that way I can execute the code to print another 500 lines.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
The easiest way to detect when they hit the button is to use a form. Otherwise you have depend on javascript, which can get messy depending on the software platforms you are working with.
 

cliftonite

Diamond Member
Jul 15, 2001
6,899
63
91
<form method=post name="next500" action="myscript.pl">
<input type=submit value="next500" name="button">
</form>

but how would I detect that? if (my $macid = $query->param('next500'); would work? kind of like a boolean?
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
I'm not sure how you would detect it in perl, but do some googling.

Try html perl forms, that should get you quite a few good sites with LOTS of examples.
 

royaldank

Diamond Member
Apr 19, 2001
5,440
0
0
Add a hidden tag in your form and then just check for that value. That would be the quickest way without having to implement any Java.
<input type="hidden" name="view" value="next500">