Checkbox required

JavaScript related questions should go here.
Post Reply
matthijs110
Posts: 10
Joined: Sat Jun 08, 2013 11:17 am

Checkbox required

Post by matthijs110 »

hi,

There is a website http://blizzardcraft.com/donations/.

There is a butten and a checkbox.

When i click on the Button (donate) without checking the checkbox, i get a pop-up screen.
when i click on the Button (donate) and have clicked on the checkbox, i will be redirected.

i found this line in the source code of the Donate button:
<input name="notify_url" value="http://blizzardcraft.com/donation_callback.php" type="hidden">
How can i make this either. I am not very good in php.

(I dont ask if someone can make it for me)

Matt
ExtremeGaming
Posts: 205
Joined: Mon Jul 09, 2012 11:13 pm

Re: Checkbox required

Post by ExtremeGaming »

This would be done with JavaScript, not PHP. However, you will need to validate it server side either way due to users that might have JavaScript disabled.

You can try this with JavaScript. Of course, you're going to need to incorporate it into your code so that the submission returns false if not checked.
if(document.getElementsByName("notify_url") === false) {
  alert("Not checked");
} else {
  // Checked
}
<?php while(!$succeed = try()); ?>
matthijs110
Posts: 10
Joined: Sat Jun 08, 2013 11:17 am

Re: Checkbox required

Post by matthijs110 »

So where do i put it?
User avatar
FrederickGeek8
Posts: 148
Joined: Wed Nov 30, 2011 10:31 pm

Re: Checkbox required

Post by FrederickGeek8 »

You would put either in the <head> wrapped in <script> tags or below all of your website contents (right before </body>)
matthijs110
Posts: 10
Joined: Sat Jun 08, 2013 11:17 am

Re: Checkbox required

Post by matthijs110 »

And then i get an popup when my checkbox is not checked? And my donate button isn't clickable without having the checkbox checked?
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: Checkbox required

Post by Temor »

matthijs110 wrote:And then i get an popup when my checkbox is not checked? And my donate button isn't clickable without having the checkbox checked?
ExtremeGaming wrote:Of course, you're going to need to incorporate it into your code so that the submission returns false if not checked.
You can't just blatantly copy & paste and expect it to work...
matthijs110
Posts: 10
Joined: Sat Jun 08, 2013 11:17 am

Re: Checkbox required

Post by matthijs110 »

I can still click on the button without having the checkbox checked.
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: Checkbox required

Post by Temor »

Please read my previous post again.
matthijs110
Posts: 10
Joined: Sat Jun 08, 2013 11:17 am

Re: Checkbox required

Post by matthijs110 »

Srry, but i just cant follow it :(
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: Checkbox required

Post by Temor »

That's because you're expecting to just copy & paste for it to work without doing any work yourself.

Ask for help on how to fix this and you'll get help.
Ask to get this done for you and you will be ignored.

Try yourself before asking and it will be much more satisfying to you when it finally does work.
matthijs110
Posts: 10
Joined: Sat Jun 08, 2013 11:17 am

Re: Checkbox required

Post by matthijs110 »

I tryed everything.

It just wont work :(
Post Reply