TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-01-2009, 11:29 PM   #1 (permalink)
The Contributor
 
Join Date: May 2008
Posts: 36
Thanks: 5
Kay1021 is on a distinguished road
Default Fancy Form checkboxes

Hey has anyone ever used this fancy form mootools check box : http://lipidity.com/fancy-form

I was trying to implement into my php but i'm having a little difficulty and it doesn't really give me too many instructions.

Could anyone help me with how to set this up

i know in the form i think it's just <input type="checkbox">Blah blah blah</input>


but then i'm not sure what variable and such i'm suppose to use to know whether it's been checked or not.

Thanks
Kay1021 is offline  
Reply With Quote
Old 06-01-2009, 11:54 PM   #2 (permalink)
The Contributor
 
Join Date: Nov 2008
Location: Sweden
Posts: 36
Thanks: 1
hjalmar is on a distinguished road
Default

First let me say that I have never used mootools (well not a lot anyways), looking at the example page it looks like any other custom-form-element-js-replacement kinda deal. :)

So in that case it's like posting of a normal form, no? what values you gonna pass? how do you access it, name? ajax?

<input type="checkbox" name="some_name" value="some_value" />
hjalmar is offline  
Reply With Quote
Old 06-02-2009, 12:01 AM   #3 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Considering the JS is correctly loaded, from the examples it appears as though the syntax for the HTML is as follows. The text won't be surrounded by an input, because inputs are self-closed (/>). Instead, it'll be contained within a label, as will the input itself.

Like so:

html4strict Code:
<label class="checked">
    <input type="checkbox" checked="checked" />
    Tick me, tick me!
</label>
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 06-02-2009, 12:05 AM   #4 (permalink)
The Contributor
 
Join Date: May 2008
Posts: 36
Thanks: 5
Kay1021 is on a distinguished road
Default

thanks guys....i haven't really used checkboxes before in forms...i was trying to read up on it....but how exactly do i use it once the user hits submit?

Basically i'm creating a checklist type deal..... so ppl check off that they did something and then add the date and comment...

thanks for the help
Kay1021 is offline  
Reply With Quote
Old 06-02-2009, 12:45 AM   #5 (permalink)
The Contributor
 
Join Date: Nov 2008
Location: Sweden
Posts: 36
Thanks: 1
hjalmar is on a distinguished road
Default

Quote:
Originally Posted by Kay1021 View Post
thanks guys....i haven't really used checkboxes before in forms...i was trying to read up on it....but how exactly do i use it once the user hits submit?

Basically i'm creating a checklist type deal..... so ppl check off that they did something and then add the date and comment...

thanks for the help
As any other form control element(unless I missunderstood your question completly). But would help if you then either said what isn't working or provide some code (or live example).
hjalmar is offline  
Reply With Quote
Old 06-02-2009, 12:56 AM   #6 (permalink)
The Contributor
 
Join Date: May 2008
Posts: 36
Thanks: 5
Kay1021 is on a distinguished road
Default

I don't have any code...because im not sure exactly how to write it all up.
Kay1021 is offline  
Reply With Quote
Old 06-02-2009, 01:06 AM   #7 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Which part are you having difficulty with?
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 06-02-2009, 05:21 AM   #8 (permalink)
The Contributor
 
Join Date: May 2008
Posts: 36
Thanks: 5
Kay1021 is on a distinguished road
Default

ok lets say i have a form

PHP Code:
<form action="page2.php" method="POST">
<
label class="checked">
    <
input type="checkbox"/>
    
Tick metick me!
</
label>
</
form
now I want to take the result of that (whether it's checked or not and input into my database so that when i display later...it will show the appropriate answer

I'm just not understanding this part of the whole thing...like what's the variable the holds this information so that input it into the database.


I'm sure this easy stuff...but for some reason i'm not getting it right now. Driving me crazy! It's not even that i'm having errors because i don't know where to start other than what's above and being connected to all the appropriate css and js.

Hope this makes sense
Kay1021 is offline  
Reply With Quote
Old 06-02-2009, 05:59 AM   #9 (permalink)
The Contributor
 
Join Date: Nov 2008
Location: Sweden
Posts: 36
Thanks: 1
hjalmar is on a distinguished road
Default

Quote:
Originally Posted by Kay1021 View Post
ok lets say i have a form

PHP Code:
<form action="page2.php" method="POST">
<
label class="checked">
    <
input type="checkbox"/>
    
Tick metick me!
</
label>
</
form
now I want to take the result of that (whether it's checked or not and input into my database so that when i display later...it will show the appropriate answer

I'm just not understanding this part of the whole thing...like what's the variable the holds this information so that input it into the database.


I'm sure this easy stuff...but for some reason i'm not getting it right now. Driving me crazy! It's not even that i'm having errors because i don't know where to start other than what's above and being connected to all the appropriate css and js.

Hope this makes sense
Well first of all what the javascript does is nothing more than visual aspect of things since the support for styling form elements vary from browser to browser.

The actual input element is then hidden or pushed out the screen with the help of css and then updated on interaction with javascript.

So do your forms as you normally would do, i.e give it a name, value and id (if you want to target that element on it's own)

Quote:
<input type="checkbox" name="some_name" value="some_value" />
Then do as you would insert any other form element to the database, as in this case is $_POST["some_name"].
hjalmar is offline  
Reply With Quote
Old 06-02-2009, 09:56 AM   #10 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Hjalmar has it spot on. Nothing changes apart from the visual aspect of things. The input it still there and behaves just like it would without the JavaScript.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 06-02-2009, 10:02 AM   #11 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

You could also check if the box is checked(for example for licence agreement tick-box).

PHP Code:
$agree $_POST['licenceagreementbox'];
if(
$agree == 'checked') { // do what you want }
else { echo 'you have to agree to licence..'; } 
__________________
Tanax is offline  
Reply With Quote
Old 06-02-2009, 06:36 PM   #12 (permalink)
The Contributor
 
Join Date: May 2008
Posts: 36
Thanks: 5
Kay1021 is on a distinguished road
Default

I kinda thought that's how it would work....but it won't send any result...it's just empty


PHP Code:
<input type="checkbox" name="check" value="unchecked"/> 
and then in the next page


PHP Code:
$check =$_POST['check'];
echo 
'CHECK RESULT: '.$check
like even if i just try to show what's in there before i start adding it to my database it just looks like this


CHECK RESULT:


empty....don't know what im doing wrong....man i hate checkboxes!
Kay1021 is offline  
Reply With Quote
Old 06-02-2009, 07:49 PM   #13 (permalink)
The Contributor
 
Join Date: May 2008
Posts: 36
Thanks: 5
Kay1021 is on a distinguished road
Default

ok i don't know how it worked but now it almost works...i was looking at the js file and saw the name chk....so i changed check to chk and now it passes the result 'on' if it's checked.....but i don't know how when i got to my results page that it will show the checked box as on now.

Like i was the check mark to remain in my table if they selected it before....all the other ones will be the x's (unchecked) until someone choses it and then it will change to checkmark
Kay1021 is offline  
Reply With Quote
Old 06-02-2009, 08:53 PM   #14 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

I've had a play, and it does appear that FancyForm uses the name attribute. Take a look at the attached file for the example I've been modifying. By clicking on the button you'll see the POST fields submitted.

html4strict Code:
<h2>TalkPHP Example</h2>

<form action='index.php' method="post">
    <label><input type="checkbox" name="SingleElement" checked="checked"> I'm a fancy cross-browser styled checkbox</label>
    <input type="submit" value="Submit Form" style='margin:1em;height:2.5em;background:#222;float:right;color:#fff'>
</form>
Attached Files
File Type: rar TalkPHP_FancyForm_Example.rar (25.8 KB, 51 views)
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
The Following User Says Thank You to Wildhoney For This Useful Post:
Kay1021 (06-02-2009)
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to locate certain checkboxes benton Javascript, AJAX, E4X 4 01-08-2009 11:04 PM
Form to submit to another form patmagpantay General 8 07-21-2008 07:42 AM
email fill in form help? PHP sacred_tinker Absolute Beginners 19 05-28-2008 05:58 AM
Contact Us Form Mohamad Script Giveaway 4 10-03-2007 02:22 PM
Form Processing William Tips & Tricks 8 04-17-2005 03:24 PM


All times are GMT. The time now is 07:21 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design