Hi,
I'm using cf as a mobile form and can't use the date/time picker.
I'd like to have 2 dropdowns, 1 for month, and one for day (year would be current year in a hidden field)
However, I'd like all 3 fields to post to the date column of my table in Year/Month/Day format.
Not sure where to start - thanx a ton for your help
Mark
I'm using cf as a mobile form and can't use the date/time picker.
I'd like to have 2 dropdowns, 1 for month, and one for day (year would be current year in a hidden field)
However, I'd like all 3 fields to post to the date column of my table in Year/Month/Day format.
Not sure where to start - thanx a ton for your help
Mark
A bit closer
Form HTML (working in v3...):
This places both values in the "text_0" column, but separates them with a comma
I need to put a "/" after the first entry, and when I have three fields, I'll need to do the same after the second entry, but not the third...
Form HTML (working in v3...):
<input class="cf_inputbox" maxlength="150" size="30" title="" id="text_0" name="text_0[]" type="text" />
<input class="cf_inputbox" maxlength="150" size="30" title="" id="text_1" name="text_0[]" type="text" />
This places both values in the "text_0" column, but separates them with a comma
I need to put a "/" after the first entry, and when I have three fields, I'll need to do the same after the second entry, but not the third...
Hi Mark,
You want implode I think:
Bob
You want implode I think:
<?php
$text_0 = Jrequest::getVar('text_0, array(), 'post, 'array');
$names = implode('/', $text_0);
?>See the PHP manual for more info.Bob
Thanx Bob,
At this point, I'd be happy just to get the value from one field to post in a different column. Once I'm clear on that I can just use multiple variables in the input value (I'm guessing...)
I tried
But nothing posted in the "text_3" column.
I tried different variations of the Jrequest line above but couldn't get it to work.
At this point, I'd be happy just to get the value from one field to post in a different column. Once I'm clear on that I can just use multiple variables in the input value (I'm guessing...)
I tried
<?php
$text_0 = Jrequest::getVar('text_0, array(), 'post, 'array');
?>
<input type="text" name = "text_0">
<input type="hidden" value="<?php echo $text_0; ?>" name = "text_3">
But nothing posted in the "text_3" column.
I tried different variations of the Jrequest line above but couldn't get it to work.
Hi Mark,
Is this CFv3 or CFv4?
Why don't you just assemble them after the form is submitted? You can't do it in the Form HTML before it loads as there are no values.
Bob
Is this CFv3 or CFv4?
Why don't you just assemble them after the form is submitted? You can't do it in the Form HTML before it loads as there are no values.
Bob
V3
I guess you've articulated what I'm wanting to do, but I have no idea how to do that.
I guess you've articulated what I'm wanting to do, but I have no idea how to do that.
Hi Mark,
If you have ChronoForms Handle arrays off
If you have ChronoForms Handle arrays on
Bob
If you have ChronoForms Handle arrays off
<?php
$text_0 = JRequest::getVar('text_0', array(), 'post, 'array');
$date = implode('/', $text_0);
JRequest::setVar('text_0', $date);
?>If you have ChronoForms Handle arrays on
<?php
$text_0 = JRequest::getVar('text_0', '', 'post);
$date = str_replace(',', '/', $text_0);
JRequest::setVar('text_0', $date);
?>Not tested and may well need debugging.Bob
Hey Bob,
Still can't get it to work,
Again, I'm trying to get $date to post to text_3 using value="<?php echo $date?>"
I used both versions of your code above with arrays turned on and off.
I added a ' to "post" - not sure if that's the right syntax,
I tried your versions as well,
Not sure what else I can debug...
Still can't get it to work,
Again, I'm trying to get $date to post to text_3 using value="<?php echo $date?>"
I used both versions of your code above with arrays turned on and off.
I added a ' to "post" - not sure if that's the right syntax,
<?php
$text_0 = JRequest::getVar('text_0', '', 'post');
$date = str_replace(',', '/', $text_0);
JRequest::setVar('text_0', $date);
?>
I tried your versions as well,
Not sure what else I can debug...
Hi Mark,
I'm sorry, I don't undersand what this means?
Bob
I'm sorry, I don't undersand what this means?
I'm trying to get $date to post to text_3 using value="<?php echo $date?>"
I thought that you were trying to save the form data to a database table? If so, what does the echo do?Bob
I'm wanting to take what's in the "text_0" input value and copy it to the "text_3" column and totally lost re what's required...
Ultimately I'd like to take values from 3 fields and copy them all into one column like
So that users could input the date using three dropdown fields - year, month, day.
Does that make sense?
I thought I could somehow add the $dates variable to the "text_3" field and it would post.
Ultimately I'd like to take values from 3 fields and copy them all into one column like
$variable1."/".$variable2."/"$variable3So that users could input the date using three dropdown fields - year, month, day.
Does that make sense?
I thought I could somehow add the $dates variable to the "text_3" field and it would post.
Hi Mark,
I've already given you the code to do this based on the HTML that you posted earlier.
What's currently in the Form HTML?
Bob
I've already given you the code to do this based on the HTML that you posted earlier.
What's currently in the Form HTML?
Bob
I tried the following but it has the same result - both values are in the text_0 column with a comma between the values - it looks like mysql is adding the comma regardless of what PHP wants it to do?
Would it be easier to something like:
And somehow get text_1 and text_2 into variables so that the text_3 value can simply be a string?
Thanx again man.
Mark
HTML:
<input class="cf_inputbox" maxlength="150" size="30" title="" id="text_0" name="text_0[]" type="text" />
<input class="cf_inputbox" maxlength="150" size="30" title="" id="text_1" name="text_0[]" type="text" />
PHP:
<?php
$text_0 = JRequest::getVar('text_0', '', 'post);
$date = str_replace(',', '/', $text_0);
JRequest::setVar('text_0', $date);
?>
Would it be easier to something like:
<input name="text_0">
<input name="text_1">
<input name ="text_3" value = "text_0.text_1">
And somehow get text_1 and text_2 into variables so that the text_3 value can simply be a string?
Thanx again man.
Mark
In the javascript box (v3), just below the html code.
Hi Mark,
Hmmm . . .The JavaScript box is intended for JavaScript to be used when the form is loaded into the browser.
You probably want your PHP in the On Submit Before Email box. Please make sure that Send Emails is set to 'Yes' on the form general tab to make sure that this box is executed.
Bob
Hmmm . . .The JavaScript box is intended for JavaScript to be used when the form is loaded into the browser.
You probably want your PHP in the On Submit Before Email box. Please make sure that Send Emails is set to 'Yes' on the form general tab to make sure that this box is executed.
Bob
That did it -
Here's what I ended up with:
in "form html" box:
in "On submit before sending email" box:
Thanx Bob for hangin' with me - I really appreciate the help!
Here's what I ended up with:
in "form html" box:
<input id="text_0" name="text_0" type="text" />
<input id="text_1" name="text_1" type="text" />
<input type="hidden" name="text_3" id="text_3" />in "On submit before sending email" box:
<?php
$text_0 = JRequest::getVar('text_0', '', 'post');
$text_1 = JRequest::getVar('text_1', '', 'post');
$date = $text_0."/".$text_1;
JRequest::setVar('text_3', $date);
?>Thanx Bob for hangin' with me - I really appreciate the help!
Hey Bob,
Can you help me with what the syntax might be for J1.7 for this? It's working fine in 1.5 but we're in the process of upgrading...
Thanx man
Can you help me with what the syntax might be for J1.7 for this? It's working fine in 1.5 but we're in the process of upgrading...
Thanx man
Nevermind, found it.
Put this in the "before emails" box
Much easier - thanx for putting this together
Put this in the "before emails" box
Much easier - thanx for putting this together
<?php
$year = $form->data['year'];
$month = $form->data['month'];
$day = $form->data['day'];
$date = $year."/".$month."/".$day;
$form->data['date_0'] = $date;
?>
This topic is locked and no more replies can be posted.
