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
messageImages along with radio buttons
Posted by: Raegann (IP Logged)
Date: February 17, 2010 04:24PM

Hi!

I'm using Ajax Linked Select boxes, something like example_7 from Salix.gr. I have database of products and I want to make something to choose a product from database. But I really need to show images along with radio buttons (under button, next to button, above button.. doesn't matter really, I think this is the least problem).

My DB structure looks like this:

CREATE TABLE IF NOT EXISTS `Katalog` (
`ID` int(10) NOT NULL auto_increment,
`Picture` varchar(50) NOT NULL,
`Model` varchar(100) NOT NULL,
`Size` varchar(100) NOT NULL,
`Price` varchar(100) NOT NULL,
`Kategory` varchar(100) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin2 AUTO_INCREMENT=436 ;

Example of insert:
(23, 'Sirius43.jpg', 'Sirius - 043', '60 - 90 ', '7 850 Kč', 'Sirius')
= Model with ID 23, Name Sirius - 043, picture Sirius43.jpg, etc.

My test page is here, I have chain select running, but I don't know how I can get there an image along with the model names? I want to show Model name and next or above the name/radio button the according image.

[dvere-zabka.cz]

Can someone help?
Here is also the core of my example_7.php:

$sc_ajax_select_boxes->add_select_box('Katalog','Kategorie','Kategorie','Kategorie','','sel1','sel_id_1','','Kategorie NOT LIKE "Z%"','Vyberte..');
$sc_ajax_select_boxes->add_radio_box('Katalog','Obrazek','Obrazek','Obrazek','','sel2','sel_id_2','');
$sc_ajax_select_boxes->add_select_box('Katalog','Kategorie','Kategorie','Kategorie','','sel3','sel_id_3','','Kategorie LIKE "Z%"','Vyberte..');
$sc_ajax_select_boxes->add_radio_box('Katalog','Model','Model','Model','','sel4','sel_id_4','');
$sc_ajax_select_boxes->link_select_boxes('sel1','sel2', 'Kategorie','');
$sc_ajax_select_boxes->link_select_boxes('sel3','sel4', 'Kategorie','');
$sc_ajax_select_boxes->place_jscripts();
?>
<form name="main" method="POST" action="example_2_posted.php">
<?php
$sc_ajax_select_boxes->show_select_box('sel1');
$sc_ajax_select_boxes->show_select_box('sel2');
$sc_ajax_select_boxes->show_select_box('sel3');
$sc_ajax_select_boxes->show_select_box('sel4');
?>
<input type="submit" value="POST" />
</form>

messageRe: Images along with radio buttons
Posted by: Raegann (IP Logged)
Date: February 17, 2010 04:26PM

PS: I use names on DB tables in my language, so
$sc_ajax_select_boxes->add_radio_box('Katalog','Obrazek','Obrazek','Obrazek','','sel2','sel_id_2','');
is the same as
$sc_ajax_select_boxes->add_radio_box('Catalog','Picture','Picture','Picture','','sel2','sel_id_2','');

messageRe: Images along with radio buttons
Posted by: Raegann (IP Logged)
Date: February 17, 2010 04:33PM

PPS: To see what I mean, the result should look like this:
[dvere-zabka.cz]

messageRe: Images along with radio buttons
Posted by: Raegann (IP Logged)
Date: February 17, 2010 05:28PM

I have it working, it was all about JS in sc_classes.php. I modified one line to:

line += '<label><input type="radio" name="'+c.name+'_opt" value="'+sValue+'" onclick="set_'+c.name+'_selected_value(this.value);" />'+sText+'<br><img src="../galerie/small_'+sValue+'" /></label>';

Now I need to make these into a table, wraping after 4 or 5 records in one row. smiling smiley
Is it class sc_form_elements this section?

var $group_pre_group = '';
var $group_post_group = '';
var $group_pre_input = '';
var $group_post_input = '<br />';

var $group_wrap_every = 4; // 0 for no wrap
var $group_pre_wrap = '';
var $group_post_wrap = '<br />';

messageRe: Images along with radio buttons
Posted by: Raegann (IP Logged)
Date: February 17, 2010 07:22PM

I have everything working for now, so now I'm only supposed to say WOW, what a wonderful script! I even don't know JS and was able to do all the changes I need in function sc_show_response_items. Really good work, clean and neat code!
Thank you very much, panos, I really appreciate your script!

messageRe: Images along with radio buttons
Posted by: Raegann (IP Logged)
Date: February 17, 2010 09:49PM

I got a little problem now. I get these errors:

mysql_connect(): Too many connections
mysql_select_db(): Can't connect to local MySQL server through socket
mysql_select_db(): A link to the server could not be established

It seems like MySQL is overloaded with connections and I believe I was the only person accessing MySQL during the creation of web pages. Am I not supposed to add somewhere into php:

mysql_close($link);

or are the connections closed by the linked select boxes script after processing and I should search some other reason?

messageRe: Images along with radio buttons
Posted by: panos (IP Logged)
Date: February 21, 2010 12:06PM

Hi great thread!!
No connection is not closed by linked selected boxes.
It is first time I ever see that error!
Example pages are not static, I have tryed up to 8 linked select boxes.
But you can add a mysql_close in ajax handler to see if solved

best regards!
Panos

messageRe: Images along with radio buttons
Posted by: Raegann (IP Logged)
Date: February 21, 2010 01:17PM

Hi,
thanks for answer! I must say I didn't see the error from the time it occurred first time, so it might be just a problem of the hosting. I'm gonna test some more and consult with the hosting company.

And I finally finished the site and it was actually quite easy to do all the modifications even for someone who isn't capable in JS. I have everything working now - linked select boxes: 2 dropdown menus for series of products and two linked radio button menus with model pictures and model names and all values are taken from DB, which is handled by administration interface I've done myself few months ago. After filling the linked select boxes the customer can send his request with mail script right to the company.
So this nice script helped me a lot to finish the complete web pages. I want to say thank you a lot just one more time. smiling smiley This is one of the best and most complex non-commercial utilities I ever saw!

Best regards,
Henry



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