Hi all!
I have make a dropdown menu that takes the options from DB:
Also there is a hidden field in the form:
You can see that I get a "dtstart" string from DB when the user selects one option from the dropdown menu. And I need to use the "dtstart" value from the selected option of dropdown menu for insert it automatically in the other (hidden) field of this form during the one step. Or using the other way for send this value to the form DB table as "time".
How can I do that?
I have make a dropdown menu that takes the options from DB:
<select class="cf_inputbox validate-selection"
id="select_1" size="1" name="select_1" title="Выберите одно">
<option value=''>Выберите, кликнув здесь</option>
<?php
if (!$mainframe->isSite() ) {return;}
$db =& JFactory::getDBO();
$query = "
SELECT `evdet_id`,FROM_UNIXTIME(dtstart,'%a, %d/%m/%y %H:%i') AS `dt_start`,FROM_UNIXTIME(dtend,'%H:%i') AS `dt_end`,`summary`
FROM `#__jevents_vevdetail`
WHERE `dtend` >= UNIX_TIMESTAMP()
ORDER BY dtstart;
";
$db->setQuery($query);
$options = $db->loadAssocList();
foreach ( $options as $o ) {
echo "<option value='".$o[dt_start]."-".$o[dt_end]." ".$o[summary]."'>".$o[dt_start]."-".$o[dt_end]." ".$o[summary]."</option>";
}
?>
</select>Also there is a hidden field in the form:
<input name="time" type="hidden" value="I NEED TO INSERT THE VALUE HERE" class="cf_inputtext cf_inputbox" maxlength="150" size="30" id="time" />You can see that I get a "dtstart" string from DB when the user selects one option from the dropdown menu. And I need to use the "dtstart" value from the selected option of dropdown menu for insert it automatically in the other (hidden) field of this form during the one step. Or using the other way for send this value to the form DB table as "time".
How can I do that?
Hi T34,
You rarely need to copy a value into a hidden input. In this case, you should just be able to transfer the value in the OnSubmit Before box:
Bob
PS If you do need to do this in the browser then it's possible with JavaScript.
You rarely need to copy a value into a hidden input. In this case, you should just be able to transfer the value in the OnSubmit Before box:
<?php
$time = JRequest::getString('select_1', '', 'post');
JRequest::setVar('time', $time);
?> Bob
PS If you do need to do this in the browser then it's possible with JavaScript.
Thank you, Bob!
I did it, but it doesn't work — the field "time" of DB string is empty after I submit the form. 😟 JavaScript is enabled in my browser.
Also I'm afraid that I didn't explain precisely what I need.
I don't need to insert the value of "select_1" into the hidden field for submit it to the "time" field of DB. I need to submit ONLY dtstart or dt_start (see the query SELECT), used by the user's selection in dropdown menu, to the field "time".
I did it, but it doesn't work — the field "time" of DB string is empty after I submit the form. 😟 JavaScript is enabled in my browser.
Also I'm afraid that I didn't explain precisely what I need.
I don't need to insert the value of "select_1" into the hidden field for submit it to the "time" field of DB. I need to submit ONLY dtstart or dt_start (see the query SELECT), used by the user's selection in dropdown menu, to the field "time".
Hi T34,
In that case a hidden input might be the best:
or am I still missing the point?
Bob
In that case a hidden input might be the best:
SELECT `evdet_id`, `dtstart`, FROM_UNIXTIME(`dtstart`,'%a, %d/%m/%y %H:%i') AS `dt_start`, FROM_UNIXTIME(`dtend`,'%H:%i') AS `dt_end`, `summary`<input type='hidden' name='time' id='time' value='<?php echo $o['dtstart']; ?>' /> or am I still missing the point?
Bob
Thank you Bob!
You understand what I need, I think. But it doesn't work properly.
The value of "input" field is constant and is equal to the latest value of "dt_start" if I use this code of "input" field. But I need this value is modified depending the user's choice in dropdown menu.
You understand what I need, I think. But it doesn't work properly.
The value of "input" field is constant and is equal to the latest value of "dt_start" if I use this code of "input" field. But I need this value is modified depending the user's choice in dropdown menu.
Hi T34,
Sorry for the delay I got sidetracked onto other projects for a while.
I'm still confused, if you are settign the options like this:
Bob
Sorry for the delay I got sidetracked onto other projects for a while.
I'm still confused, if you are settign the options like this:
echo "<option value='".$o[dt_start]."-".$o[dt_end]." ".$o[summary]."'>".$o[dt_start]."-".$o[dt_end]." ".$o[summary]."</option>"then could you not change this to echo "<option value='".$o[dt_start]."'>".$o[dt_start]."-".$o[dt_end]." ".$o[summary]."</option>"so that the value is dt_start?Bob
Hi Bob!
I need the string in dropdown menu as 'Вск, 05 января 20011 г. 11:00-19:00 "По-Другому"' where are the weekday, the date, the time of the beginning and the time of the end, the name of the event - for users can select the value with all minimum required information. And I need to have the form result in the database in the format 'Вск, 05 января 20011 г. 11:00-19:00 "По-Другому"' too or the similar. So I use this syntax in the "option value".
But also I need to sort this DB strings in CC form by UNIXTIME format of the original `dtstart` value of the event. I may use the DB output like "1295758800, Вск, 05 января 20011 г. 11:00-19:00 "По-Другому" certainly and sort it simply, but I'd like to avoid this way because the view should be too bulky.
So I'd like to have the different fields in the string of DB table for the name of event with date etc. like 'Вск, 05 января 20011 г. 11:00-19:00 "По-Другому"' and the 'UNIXTIME' data of the beginning of the event. In this case I should can use the sorting in CC form using `dtstart` but see the strings like 'Вск, 05 января 20011 г. 11:00-19:00 "По-Другому"'.
I need the string in dropdown menu as 'Вск, 05 января 20011 г. 11:00-19:00 "По-Другому"' where are the weekday, the date, the time of the beginning and the time of the end, the name of the event - for users can select the value with all minimum required information. And I need to have the form result in the database in the format 'Вск, 05 января 20011 г. 11:00-19:00 "По-Другому"' too or the similar. So I use this syntax in the "option value".
But also I need to sort this DB strings in CC form by UNIXTIME format of the original `dtstart` value of the event. I may use the DB output like "1295758800, Вск, 05 января 20011 г. 11:00-19:00 "По-Другому" certainly and sort it simply, but I'd like to avoid this way because the view should be too bulky.
So I'd like to have the different fields in the string of DB table for the name of event with date etc. like 'Вск, 05 января 20011 г. 11:00-19:00 "По-Другому"' and the 'UNIXTIME' data of the beginning of the event. In this case I should can use the sorting in CC form using `dtstart` but see the strings like 'Вск, 05 января 20011 г. 11:00-19:00 "По-Другому"'.
Hi 34,
You can see that this thread links to the other one How to add a search to a ChronoConnectivity form In both cases - in part at least you are getting into trouble by trying to do too much with the option values.
Using the full string 09.01.11/11:00-19:00/"По-Другому" or Вск, 05 января 20011 г. 11:00-19:00 "По-Другому" in the display part of the option tag i.e. between the <option> & </option> tags is fine. Using these in the value attribute is not working.
There are a couple of reasons for this. One is that the punctuation in these strings is breaking the MySQL in some cases . . . quotes, slashes, dashes and colons are not good characters to be trying to match on. The other is that there is simply too much data to be useful, you are packing dates and times into a single variable.
If you are going to do this then I'd suggest that the table should have:[list]a column with a simple identifier (I tend to use a random string but an auto-incremented integer would be OK) A separate column for the start date that you can use for sorting A third column for the label - which can include all of these (or be constructed in the DB query using CONCAT() other columns, if needed, for the times, places, end dates, etc. [/list]
Bob
You can see that this thread links to the other one How to add a search to a ChronoConnectivity form In both cases - in part at least you are getting into trouble by trying to do too much with the option values.
Using the full string 09.01.11/11:00-19:00/"По-Другому" or Вск, 05 января 20011 г. 11:00-19:00 "По-Другому" in the display part of the option tag i.e. between the <option> & </option> tags is fine. Using these in the value attribute is not working.
There are a couple of reasons for this. One is that the punctuation in these strings is breaking the MySQL in some cases . . . quotes, slashes, dashes and colons are not good characters to be trying to match on. The other is that there is simply too much data to be useful, you are packing dates and times into a single variable.
If you are going to do this then I'd suggest that the table should have:[list]
Bob
Thanks Bob!
It's a good idea, but how can I send the some values to the some table fields from one dropdown menu? This is a main problem!
It's a good idea, but how can I send the some values to the some table fields from one dropdown menu? This is a main problem!
Hi T34,
If you use the short-code method, then you can look the values up in the OnSubmit Before Email box after the form is submitted.
Bob
If you use the short-code method, then you can look the values up in the OnSubmit Before Email box after the form is submitted.
Bob
Hi T34,
If you use the short-code method, then you can look the values up in the OnSubmit Before Email box after the form is submitted.
Bob
Hi Bob!
Hmmm... Thanks, but I don't need to look at the Email Box, I need the form allocates the parts of query to the different fields of DB table after the user presses "Submit" button, because then I use this table for CC form with sorting by 'dtstart' value. How can I do that?
OK, I didn't understand before that you mean the "On Submit code - before sending email" field in admin panel. 🙂 But I don't know how the usage of this field can help me to sent the some values to the different table fields from the ONE dropdown menu. Please, explain me this or give me a link to any examples.
Also would can you write what you mean using the term "short-code method"? What is it?
Also would can you write what you mean using the term "short-code method"? What is it?
Hi Bob!
Now I use the other request:
with the hidden field
but I have only the latest value in "time" field after submit anywhere. 😟 Is it possible technically to insert one of the requested values of dynamical dropdown menu to the specific field of CF?
Now I use the other request:
<select class="cf_inputbox validate-selection required"
id="select_1" size="1" name="select_1" title="Выберите одно">
<option value=''>Выберите, кликнув здесь</option>
<?php
if (!$mainframe->isSite() ) {return;}
$db =& JFactory::getDBO();
$query = "
SELECT `evdet_id`, `dtstart`, CONCAT(FROM_UNIXTIME(dtstart,'%a, %d/%m/%y|%H:%i -'), FROM_UNIXTIME(dtend,' %H:%i|'), `summary`) AS `full_event`
FROM `#__jevents_vevdetail`
WHERE `dtend` >= UNIX_TIMESTAMP()
ORDER BY dtstart;
";
$db->setQuery($query);
$options = $db->loadAssocList();
foreach ( $options as $o ) {
echo "<option value='".$o[full_event]."'>".$o[full_event]."</option>";
}
?>
</select>with the hidden field
<input type='hidden' name='time' id='time' value='<?php echo $o['dtstart']; ?>' />but I have only the latest value in "time" field after submit anywhere. 😟 Is it possible technically to insert one of the requested values of dynamical dropdown menu to the specific field of CF?
Hi T34,
You can use code in the OnSubmit Before box to divide up the string from the drop-down - or better to use the short-code from the drop down to look up any and all of the information you need.
By all means email or PM me the site URL and a SuperAdmin login and I'll take a quick look.
Bob
Thanks, but I don't need to look at the Email Box,
Sorry, the OnSubmit Before Email box doesn't have anything particularly to do with Emails. It's a convenient place to process the form results before they are saved (or emailed).You can use code in the OnSubmit Before box to divide up the string from the drop-down - or better to use the short-code from the drop down to look up any and all of the information you need.
By all means email or PM me the site URL and a SuperAdmin login and I'll take a quick look.
Bob
Hi T34,
Interesting that you have a site with Hellinger's Constellation work !
I have copied a form a listing for you to look at.
The form zayavka_reg_bob (no 22) is a simplified version of your test form. I have removed all the hidden inputs and changed the drop-down to use the edvet_id as the value.
I also changed the input names to be more meaningful than 'select_1', etc.
I created a new table that saves the edvet_id, and the two radio button results plus the standard ChronoForms info (these include the user id and the date/time of submission so you don't need those in the form).
I copied the last ChronoConnectivity listing to zayavki_constel_user_bob (using the cc_copy form) and have also edited that.
The select box now shows a list of the events for which there are bookings - using SELECT DISTINCT to get the unique values from the new table, and a JOIN to the JEvents table to get the detailed info.
The listing gets the info for each user by calling JFactory::getUser($MyRow->cf_user_id) and also picks up the Event detail from the information loaded in the Header box to create the select box.
This isn't complete or perfect but should give you some ideas for the next step of development.
Bob
Interesting that you have a site with Hellinger's Constellation work !
I have copied a form a listing for you to look at.
The form zayavka_reg_bob (no 22) is a simplified version of your test form. I have removed all the hidden inputs and changed the drop-down to use the edvet_id as the value.
I also changed the input names to be more meaningful than 'select_1', etc.
I created a new table that saves the edvet_id, and the two radio button results plus the standard ChronoForms info (these include the user id and the date/time of submission so you don't need those in the form).
I copied the last ChronoConnectivity listing to zayavki_constel_user_bob (using the cc_copy form) and have also edited that.
The select box now shows a list of the events for which there are bookings - using SELECT DISTINCT to get the unique values from the new table, and a JOIN to the JEvents table to get the detailed info.
The listing gets the info for each user by calling JFactory::getUser($MyRow->cf_user_id) and also picks up the Event detail from the information loaded in the Header box to create the select box.
This isn't complete or perfect but should give you some ideas for the next step of development.
Bob
Hi, Bob!
This is my personal site, and the psychological constellations (not only Hellinger's) is my job. 😉
Thanks a lot for you help! This solution is very interesting! 🙂
But this is a great problem in it. I need to send a letter after a form will be submitted. This form includes the value "full_event" as description like "Where and when the event shall have place:" of the letter. After you modify the result of select of the dropdown menu to the number of event id, I can only take this number in the letters instead the normal description. I hope it's possible to include the descriptions to the letters using "On Submit code - before sending email:" field, but I'm not sure, and I don't know how to do that.
I need your help again!
This is my personal site, and the psychological constellations (not only Hellinger's) is my job. 😉
Thanks a lot for you help! This solution is very interesting! 🙂
But this is a great problem in it. I need to send a letter after a form will be submitted. This form includes the value "full_event" as description like "Where and when the event shall have place:" of the letter. After you modify the result of select of the dropdown menu to the number of event id, I can only take this number in the letters instead the normal description. I hope it's possible to include the descriptions to the letters using "On Submit code - before sending email:" field, but I'm not sure, and I don't know how to do that.
I need your help again!
This topic is locked and no more replies can be posted.
