Re: [PHP] Re: checkboxes
PJ wrote: Ashley Sheridan wrote: On Wed, 2009-04-22 at 07:17 +0530, kranthi wrote: yeh an onclick event handler is required to achieve this. but as Shawn has suggested radio buttons are better in this case. but then again if u want to disable/greyout the other input(like textboxes, other than the radio button itself) u'll hav to use onclick event handler for the radio buttons Not necessarily, you could use CSS to change the background colour: input[checked=checked] { set styles here } I see that Shawn's suggested radio buttons will do just fine. I hadn't thought about that. Dummy me. But the real problem I have is to pass a form input value to a variable. For example: input type=text name=titleIN size=52 / input type=radio name=choice value=$titleIN / How can I pass the text input to a variable that could be used by the radio button? The idea is to have several inputs for a search page with the inputs limited by the radio button to one choice of several inputs. If I can get the input to a variable, I can then manipulate it to do a query for the search. :-\ Hope this is understandable? Here's something I found but don't understand if or how it could be used: (from php.net manual) |quote... snip... to reliably allow form data to be fed back into a form (for editing a record, for instance) is like this: echo input type='text' name='varname' ; if(isset($existingvalue)) echo value=\.htmlspecialchars(stripslashes($existingvalue)).\ ; echo /; This assumes that variables have been escaped (such as addslashes) after being retrieved from the database or after being received from a (probably this) form. endquote From this form??? How would you get the $existingvalue? from the form? How? I'm trying, I'm trying... Phil | -- unheralded genius: A clean desk is the sign of a dull mind. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: checkboxes
On Wed, 2009-04-22 at 01:38 -0400, PJ wrote: Ashley Sheridan wrote: On Wed, 2009-04-22 at 07:17 +0530, kranthi wrote: yeh an onclick event handler is required to achieve this. but as Shawn has suggested radio buttons are better in this case. but then again if u want to disable/greyout the other input(like textboxes, other than the radio button itself) u'll hav to use onclick event handler for the radio buttons Not necessarily, you could use CSS to change the background colour: input[checked=checked] { set styles here } I see that Shawn's suggested radio buttons will do just fine. I hadn't thought about that. Dummy me. But the real problem I have is to pass a form input value to a variable. For example: input type=text name=titleIN size=52 / input type=radio name=choice value=$titleIN / How can I pass the text input to a variable that could be used by the radio button? The idea is to have several inputs for a search page with the inputs limited by the radio button to one choice of several inputs. If I can get the input to a variable, I can then manipulate it to do a query for the search. :-\ Hope this is understandable? -- unheralded genius: A clean desk is the sign of a dull mind. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php Just accept all the text inputs from the form, and use a switch on the radio button to determine which of the text inputs you use. Alternatively, just use one text box for input and use the value of the radio button to determine what to do with the text. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: checkboxes
i find var_dump, trigger_error really useful in situations like these. just do var_dump($_POST); var_dump($_GET); in the action{.php} script and u'll find a good deal of useful information -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: checkboxes
Ashley Sheridan wrote: On Wed, 2009-04-22 at 01:38 -0400, PJ wrote: Ashley Sheridan wrote: On Wed, 2009-04-22 at 07:17 +0530, kranthi wrote: yeh an onclick event handler is required to achieve this. but as Shawn has suggested radio buttons are better in this case. but then again if u want to disable/greyout the other input(like textboxes, other than the radio button itself) u'll hav to use onclick event handler for the radio buttons Not necessarily, you could use CSS to change the background colour: input[checked=checked] { set styles here } I see that Shawn's suggested radio buttons will do just fine. I hadn't thought about that. Dummy me. But the real problem I have is to pass a form input value to a variable. For example: input type=text name=titleIN size=52 / input type=radio name=choice value=$titleIN / How can I pass the text input to a variable that could be used by the radio button? The idea is to have several inputs for a search page with the inputs limited by the radio button to one choice of several inputs. If I can get the input to a variable, I can then manipulate it to do a query for the search. :-\ Hope this is understandable? -- unheralded genius: A clean desk is the sign of a dull mind. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php Just accept all the text inputs from the form, You mean, submit? to the originating page? I'm trying to use $_POST, so action=this_file.php? Then manipulate the results and pass them to a query and then display on page. Right? and use a switch on the radio button to determine which of the text inputs you use. But how do you use the above - switch on the radio button ? Alternatively, just use one text box for input and use the value of the radio button to determine what to do with the text. Don't understand this either. I must really be stupid for I have been trying both methods and I just don't know how to deal with this... -- unheralded genius: A clean desk is the sign of a dull mind. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: checkboxes
On Wed, 2009-04-22 at 14:55 -0400, PJ wrote: Ashley Sheridan wrote: On Wed, 2009-04-22 at 01:38 -0400, PJ wrote: Ashley Sheridan wrote: On Wed, 2009-04-22 at 07:17 +0530, kranthi wrote: yeh an onclick event handler is required to achieve this. but as Shawn has suggested radio buttons are better in this case. but then again if u want to disable/greyout the other input(like textboxes, other than the radio button itself) u'll hav to use onclick event handler for the radio buttons Not necessarily, you could use CSS to change the background colour: input[checked=checked] { set styles here } I see that Shawn's suggested radio buttons will do just fine. I hadn't thought about that. Dummy me. But the real problem I have is to pass a form input value to a variable. For example: input type=text name=titleIN size=52 / input type=radio name=choice value=$titleIN / How can I pass the text input to a variable that could be used by the radio button? The idea is to have several inputs for a search page with the inputs limited by the radio button to one choice of several inputs. If I can get the input to a variable, I can then manipulate it to do a query for the search. :-\ Hope this is understandable? -- unheralded genius: A clean desk is the sign of a dull mind. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php Just accept all the text inputs from the form, You mean, submit? to the originating page? I'm trying to use $_POST, so action=this_file.php? Then manipulate the results and pass them to a query and then display on page. Right? and use a switch on the radio button to determine which of the text inputs you use. But how do you use the above - switch on the radio button ? Alternatively, just use one text box for input and use the value of the radio button to determine what to do with the text. Don't understand this either. I must really be stupid for I have been trying both methods and I just don't know how to deal with this... -- unheralded genius: A clean desk is the sign of a dull mind. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php Say your search form has three radio buttons for the possible search criteria; date, title and category, and in the form, next to each is a textbox to accept the input for it. In the PHP code you would do something like this: $type = $_POST['type']; switch($type) { case 'date': { // process date text box here break; } case 'title': { // process title text box here break; } case 'category': { // process category text box here break; } } And you radio buttons would be like this: input type=radio name=type value=date/ input type=radio name=type value=title/ input type=radio name=type value=category/ Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: checkboxes
yeh an onclick event handler is required to achieve this. but as Shawn has suggested radio buttons are better in this case. but then again if u want to disable/greyout the other input(like textboxes, other than the radio button itself) u'll hav to use onclick event handler for the radio buttons -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: checkboxes
On Wed, 2009-04-22 at 07:17 +0530, kranthi wrote: yeh an onclick event handler is required to achieve this. but as Shawn has suggested radio buttons are better in this case. but then again if u want to disable/greyout the other input(like textboxes, other than the radio button itself) u'll hav to use onclick event handler for the radio buttons Not necessarily, you could use CSS to change the background colour: input[checked=checked] { set styles here } Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: checkboxes
Ashley Sheridan wrote: On Wed, 2009-04-22 at 07:17 +0530, kranthi wrote: yeh an onclick event handler is required to achieve this. but as Shawn has suggested radio buttons are better in this case. but then again if u want to disable/greyout the other input(like textboxes, other than the radio button itself) u'll hav to use onclick event handler for the radio buttons Not necessarily, you could use CSS to change the background colour: input[checked=checked] { set styles here } I see that Shawn's suggested radio buttons will do just fine. I hadn't thought about that. Dummy me. But the real problem I have is to pass a form input value to a variable. For example: input type=text name=titleIN size=52 / input type=radio name=choice value=$titleIN / How can I pass the text input to a variable that could be used by the radio button? The idea is to have several inputs for a search page with the inputs limited by the radio button to one choice of several inputs. If I can get the input to a variable, I can then manipulate it to do a query for the search. :-\ Hope this is understandable? -- unheralded genius: A clean desk is the sign of a dull mind. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: checkboxes
I have another idea - to use javascript to change hidden value (input type=hidden id=chkbox value=0) When you check this box - javascript changes hidden value to 1 and submits form ( function chkboxAndSubmit() { var box_name = document.GetElementById('box_name'); var chkbox = document.GetElementById('chkbox'); if (box_name.checked===true) { box_name.checked = false; documen.chkbox.value = 0; } else { box_name.checked = true; documen.chkbox.value = 1; } document.form_name.submit(); } ) and then after submitting document you must create (if it uses only function - variable must be global) variable with name $chkbox and check - if (chkbox==1) //checked else //unchecked
Re: [PHP] Re: checkboxes
use onClick event handler for the checkbox and inside the handler check if checkbox.checked==true then call your checked handler else call unchecked handler HTH - Original Message - From: Ben Holt [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, October 26, 2001 6:13 PM Subject: [PHP] Re: checkboxes Sounds like onChange to me... when you check it you change it, when you uncheck it you change it. - Ben Boaz Yahav wrote: does anyone know the HTML event that knows when a checkbox has been checked and unchecked? So far I'm using onChange but that is not exactly what I need. I need to run one JS function when a checkbox is checked and another when it is unchecked. NE1? berber -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]