Open Source & Stuff  
  |     Main Site     |      Forum     |     Contact     |
Ajax Linked Select boxes :  forum.Salix.gr forum.Salix.gr
Comments, questions, usage, bugs. 
Goto Thread: PreviousNext
Goto: Forum ListMessage ListNew TopicSearchLog In
messagelinked radiobutton prob
Posted by: jerry (IP Logged)
Date: May 12, 2008 01:15PM

Hi panos: I've been using the linked select boxes script and it works very good, but now i'm having some troubles. Let me explain:

I use three linked select boxes to go through some databases and I'd like to use a textbox to put a field from the last chosen register from the 3rd select box, I've used another select box to get that field and it worked fine, but it looks bad for only one option to be there so I tried the radio button way, and this is where i'm having trouble. I supposed it should work by to things:

creating another selectbox function in order to call the add_radio_group instead of the add_select_box and to change the parameters sent to get_list_from_db. Let me show you how it looks now:

function show_select_box($box_name) {
if( array_key_exists($box_name, $this->select_boxes) ) {
$sc_form_elements = new sc_form_elements();
$link_field='';
$link_field_selected='';
$extra = $this->select_boxes[$box_name]['extra'];
$sc_form_elements->select_prompt_text=$this->select_boxes[$box_name]['select_prompt_text'];
if( $this->_is_select_parent($box_name) ) {
$childs = $this->_get_select_childs($box_name);
$extra .= ' onchange="get_'.$box_name.'_childs_sub_items();" ';
}
if( $this->_is_select_child($box_name) ) {
$parent = $this->_get_select_parent($box_name);
if( $parent ) {
$link_field=$parent['link_field'];
$link_field_selected=$parent['link_field_selected'];
}
}
$list = $this->get_list_from_db(
$this->select_boxes[$box_name]['table_name'],
$this->select_boxes[$box_name]['key_field'],
$this->select_boxes[$box_name]['text_field'],
$this->select_boxes[$box_name]['order_field'],
$link_field,$link_field_selected,
$this->select_boxes[$box_name]['extra_where']);

$sc_form_elements->add_select_box($list,
$this->select_boxes[$box_name]['selected'],
$box_name,
$this->select_boxes[$box_name]['id'],
$extra);
echo '<br />';
}
} // end function show_select_box -----------------------------------

function show_select_box2($box_name) {
if( array_key_exists($box_name, $this->select_boxes) ) {
$sc_form_elements = new sc_form_elements();
$link_field='';
$link_field_selected='';
$extra = $this->select_boxes[$box_name]['extra'];
$sc_form_elements->select_prompt_text=$this->select_boxes[$box_name]['select_prompt_text'];
if( $this->_is_select_parent($box_name) ) {
$childs = $this->_get_select_childs($box_name);
$extra .= ' onchange="get_'.$box_name.'_childs_sub_items();" ';
}
if( $this->_is_select_child($box_name) ) {
$parent = $this->_get_select_parent($box_name);
if( $parent ) {
$link_field=$parent['link_field'];
$link_field_selected=$parent['link_field_selected'];
}
}
$list = $this->get_list_from_db(
$this->select_boxes[$box_name]['table_name'],
$this->select_boxes[$box_name]['key_field'],
$this->select_boxes[$box_name]['text_field'],
$this->select_boxes[$box_name]['order_field']);

$sc_form_elements->add_radio_group($list,
$this->select_boxes[$box_name]['selected'],
$box_name,
$this->select_boxes[$box_name]['id'],
$extra);
echo '<br />';
}
} // end function show_select_box2 -----------------------------------

the problem is that this makes me a radiobutton group that send to me the field that i look for but from ALL the table, and not from the preselected register from de linked select boxes.

any idea what's going on?
I mean after all when it works I'll like to change the radio button to a textbox but I think there should not be a problem with that.

How I made myself clear, i'm not thaaaat good explaining things... LOL

Thanks for your time.

Jerry

messageRe: linked radiobutton prob
Posted by: jerry (IP Logged)
Date: May 12, 2008 02:38PM

Hi again Panos:

I think my real problem is that i don't know how to link the radio button so that when the 3rd select box has an option chosen the radiobutton can get the info i need from that register.

Thanks for the help.

Jerry

messageRe: linked radiobutton prob
Posted by: panos (IP Logged)
Date: May 13, 2008 08:30AM

Hi Jerry,

Quote:
I use three linked select boxes to go through some databases and I'd like to use a textbox to put a field from the last chosen register from the 3rd select box,

I think just with a little javascript you could take that value and show it in a text box.
Take a look at the demo [www.salix.gr]
That shows in a alert but you can show it in text box.

Simpler.

messageRe: linked radiobutton prob
Posted by: jerry (IP Logged)
Date: May 13, 2008 09:59AM

yeap. I've already tried it that way and it returns the rec_id i need but with that rec_id I need it to perform a query, and I haven't managed to achieve it without refreshing the page... sad smiley

messageRe: linked radiobutton prob
Posted by: panos (IP Logged)
Date: May 14, 2008 04:04AM

hmm.... you need the text of the selection and not rec_id?
if you can get it from select box also with little more javascript winking smiley

messageRe: linked radiobutton prob
Posted by: jerry (IP Logged)
Date: May 14, 2008 12:22PM

Hi Panos:

This is the URL link for my webpage:

[proaseguros.com]

I need the info in the 5th,6th & 7th select boxes to be put in a radiobutton or a texbox, and I need to link them to the select 4th select box.

I used javascript before to store the rec_id value in a cookie and then read it with PHP and search the prices via a mysql_query of the selected car, but I only managed to get the prices by refreshing the page. sad smiley

I need the prices to charge dinamically as it now works with the select boxes but with a radio button or textbox.

If you could tell me what should I change in your code to get this done, it'd be great 'cause I stucked at this.

Thanks again for your time Panos.

Hope to hear from you soon! smiling smiley

Jerry

Jerry

messageRe: linked radiobutton prob
Posted by: panos (IP Logged)
Date: May 19, 2008 05:06AM

I am back smiling smiley

I was in bed sick for 4 days sad smiley

ok, lets see... you get the 3 price types for the selected car model using the selected id of the model? or something more?
the 3 prices are in 1 row of the table or more?

can you mail me table structures and some sample data?

you gave me an idea for a new little ajax thing.
Firing from the last select box make an ajax call to get values from table and update given tags. Given couples of field-tag_id like:

'AmpliaGL' => 'price_1',
'Amplia' => 'price_2',
'Limitada' => 'price_3'

table name and where clause in someway (thinking of it now) and it will make the ajax call and then update the tags with the values of the fields.

How does it sound?
You think something like it would be useful?



Edited 1 time(s). Last edit at 05/19/2008 07:49AM by panos.

messageRe: linked radiobutton prob
Posted by: jerry (IP Logged)
Date: May 19, 2008 12:06PM

Hi Panos:

I'm sorry to tell you this but.... .... THAT'S EXACTLY HOW IT WORKS AND WHAT I NEED hahahaha yeah!!

Yeap, the prices are read from the same register of the selected id, and the prob is just to make these prices updated each time we change the model of the car (it would be better in textboxes)... i'll send you my table structures and some samples.

I really appreciate this.

Thanks again.

Jerry

messageRe: linked radiobutton prob
Posted by: panos (IP Logged)
Date: May 23, 2008 06:16AM

JERRY!!

take a look at [www.salix.gr]. Download [www.salix.gr] test and tell me what you think.



Edited 1 time(s). Last edit at 05/23/2008 06:18AM by panos.

messageRe: linked radiobutton prob
Posted by: panos (IP Logged)
Date: May 27, 2008 03:01AM

worked?

messageRe: linked radiobutton prob
Posted by: jerry (IP Logged)
Date: May 27, 2008 09:57AM

Hi Panos, I'm having some trouble implementing your example so as soon as I figure it out I'll let you know, I got the tables and database on my server and hoped It worked fine but I it doesn't, i think I did somethnig wrong... I'll keep lookin, nay change I'll let you know.

smiling smiley

messageRe: linked radiobutton prob
Posted by: panos (IP Logged)
Date: May 28, 2008 02:32AM

Sorry!
My bad!
download attached file from [www.salix.gr] the correct sample database.
A table is missing from sample database in zip file.

messageRe: linked radiobutton prob
Posted by: jerry (IP Logged)
Date: June 13, 2008 01:25PM

Hi Panos, I've implemented your updater .zip file and it works well, but when I try to implement it with my page I just don't know why it doesn't returns any value, and the innerHTML you put there to see what the server is receiving and answering shows the info is just fine.

By the way, something that your script does is that the updater class has to refer to a table where the key_fields are just numbers, that is because i noticed that when, for example, my key field had the value "st51" it requested for the value "51". I also eliminated the "click me" button since it didn't seem to be working, and did the same with the "clean" button since I don't need it that much. I'll send you by e-mail my page's code and the exact sc_classes and top_script I am using to get it to work. Hope you can help me with this little issue.

Wishing you the best.
Jerry

messageRe: linked radiobutton prob
Posted by: panos (IP Logged)
Date: June 19, 2008 02:34AM

just for the records, all Jerry's issues solved as he told me in his last email.

Happy coding
Jerry



Sorry, only registered users may post in this forum.

All Rights Reserved 2006 Salix.gr  |  Design by Ades Design |  Hosting by e-emporio |  forum.Salix.gr powered by Phorum