I am trying to run a script silenty by asking the user to tick a check box.
So the check box goes from empty to being a cross, but also runs the script.
I am sure I have seen this before but I can't find a working example.
Your help is very much appreciated as I am running out of hair ... :-)
Tim
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32599
4
posted
0
Welcome to JavaRanch
I was going to tell you to go to the JCheckBox API and find what Listeners you can add to a JCheckBox. Then I saw it gives a link to the Java Tutorials where you can find an example. I think that uses a ChangeListener.
You can also add an ActionListener, but I think that only fires when the box is checked, not un-checked.
Since we usually discuss these things on the Swing forum I shall move you there.
"tim jigsaw", please check your private messages regarding an important administrative matter.
Thank you.
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
a checkbox is a button
from the apidocs
Timothy M Smith
Greenhorn
Joined: Aug 19, 2009
Posts: 2
posted
0
Thanks for your comments and help so far, but I am still a little stuck here.
I am trying to build a WiFi landing page and essentially I want the user to agree to the t & c's, by doing this they send the user and password to my box and it opens the internet portal up to the user.
Below is the full html and the small Java script that checks and ensures the user agrees to the terms and conditions etc
What I am trying to do here is get the checkbox to run the login form.
So obviously changing the checkbox to button does this, But I want to add further functionality to my page and want to run a further script that will direct them to another URL. (this I can do as I found this on your site already!!)
However you may want to point me in the direction of the tutorial as this is alot to ask, but I did read the posts but I am still some what lost!!!
function checkCheckBox(f){
if (f.agree.checked == false )
{
alert('Please read the terms and conditions and check the box to continue.');
return false;
}else
return true;
}