Support Forums

Old 02-16-2009, 10:37 AM   #1
Member
 
Join Date: Aug 2008
Posts: 63
Rep Power: 4
nagrap2 is on a distinguished road
Default Copy One Form Value to Another

Hi,

I am trying to capture a user's date of birth during the registration page in 3 fields.

I want to use the "extra" field to store the date of birth, however, at the point at which i am capturing the date I am displaying 3 fields to the user (1 for day, 1 for month and 1 for year).

I then want to capture what the user has entered in these 3 fields and concatenate all three values as an input to the "extra" field so it can be saved in the database. I have also made the "extra" field a hidden text field as there is no need for the user to see this.

The issue i am getting is the extra field always stays blank.

I have used the following code, anyone got any ideas what I am doing wrong or smaple code to help resolve this issue?

within userjoin.tpl (I have removed the actual code to populate the values for the drop downs to save on space):

{if $dis_extra=="Y"}
{* Date of Birth *}
<tr>
<td class="formleft">{$extra_text}{$smarty.const.LANG_ COLON}</td>
<td class="formright">
<select name="BirthDays" id="BirthDays">
...code to populate the days dropdown...
</select>
<select nameid="BirthMonths" id="BirthMonths">
...code to populate the months dropdown...
</select>
<select name="BirthYears" id="BirthYears">
...code to populate the years dropdown...
</select>
{if $req_extra=="Y"} <span class='required'>{$smarty.const.LANG_STAR}</span>{/if}
<td class="formright"><input type="hidden" name="extra" id="extra" value="{$BirthDays}{$BirthMonths}{$BirthYears}" /></td>
</td>
</tr>
{/if}
__________________
Many Thanks,

Nagrap2

Developer Version 4.1
nagrap2 is offline   Reply With Quote
Old 02-16-2009, 10:53 AM   #2
Moderator
 
 
Join Date: Mar 2006
Posts: 4,114
Rep Power: 101
Lhotch is just really niceLhotch is just really nice
Default

Smarty
__________________
Larry.
(Please note: I am not a 68C employee. I am a customer and volunteer who helps with questions where I can and the forums spam free)

Set your site apart from the competition with one of my modules......
Google Map Module | You Tube Module | Google Calendar Module | Event Calendar Module

68 Classifieds Important Links
Customer Area | Issue Tracker | Knowledge Base | User Manuals
Lhotch is offline   Reply With Quote
Old 02-16-2009, 11:03 AM   #3
Member
 
Join Date: Aug 2008
Posts: 63
Rep Power: 4
nagrap2 is on a distinguished road
Default

Larry,

I wasnt sure how the above applies to my scenario? As none of my vairables have anything other than letters?
__________________
Many Thanks,

Nagrap2

Developer Version 4.1
nagrap2 is offline   Reply With Quote
Old 02-16-2009, 11:15 AM   #4
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,776
Rep Power: 110
Eric Barnes is a jewel in the rough
Default

Actually I can only think of two ways of doing this.

1. Use javascript and a hidden form element that would take the values from those three and join them into one hidden field.

2. Edit the php and join those three into the one variable the script uses.
__________________
Eric Barnes
68 Classifieds Developer
Please do not send me a private message asking for support. Instead use these open forums or our ticket system.

Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 02-16-2009, 11:19 AM   #5
Moderator
 
 
Join Date: Mar 2006
Posts: 4,114
Rep Power: 101
Lhotch is just really niceLhotch is just really nice
Default

The reason I pointed you to that page has nothing to do with your variables containing only letters. I pointed you to that page as a possible solution by using back tics.

The truth of the matter is im not even sure if your approach will work. The smarty variables declared to hold the various pieces of the birth date arent technically populated yet as far as smarty and the scripts are concerned because the form hasnt been submitted.

Another approach would be to do the concatenation at the PHP level.
__________________
Larry.
(Please note: I am not a 68C employee. I am a customer and volunteer who helps with questions where I can and the forums spam free)

Set your site apart from the competition with one of my modules......
Google Map Module | You Tube Module | Google Calendar Module | Event Calendar Module

68 Classifieds Important Links
Customer Area | Issue Tracker | Knowledge Base | User Manuals
Lhotch is offline   Reply With Quote
Old 02-16-2009, 11:44 AM   #6
Member
 
Join Date: Aug 2008
Posts: 63
Rep Power: 4
nagrap2 is on a distinguished road
Default

Larry / Eric,

Thanks.... so if i were to do the concatenation at the php level can you give me some sample code? I just need a pointer to get me started... which file would I edit, is it the userjoin.php?
__________________
Many Thanks,

Nagrap2

Developer Version 4.1
nagrap2 is offline   Reply With Quote
Old 02-16-2009, 11:52 AM   #7
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,776
Rep Power: 110
Eric Barnes is a jewel in the rough
Default

Yes userjoin.php.

Find:
// Build an array from the submitted form values

Just below it add your new values and assign them to a variable:
$myextra = $_POST['BirthDays'] . $_POST['BirthMonths'] . $_POST['BirthYears'];

Then replace one of these with your new variable:
Code:
'extra'=>trim(@$_POST['extra']),
                    'extra2'=>trim(@$_POST['extra2']),
                    'extra3'=>trim(@$_POST['extra3']),
If it is the extra2 field then:
'extra2'=>$myextra,
__________________
Eric Barnes
68 Classifieds Developer
Please do not send me a private message asking for support. Instead use these open forums or our ticket system.

Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 02-16-2009, 12:15 PM   #8
Member
 
Join Date: Aug 2008
Posts: 63
Rep Power: 4
nagrap2 is on a distinguished road
Default

Eric,

That's fantastic, it worked !!!

OK last question, I would also want to provide the user with the option of updating this via "Modify User Account" option.

I will write some logic to retrieve the data from the "extra" field and strip it down so it displays the data again in 3 fields. However, on submit, what would I modify within useraccountmodify.php to be able to save the user's changes?

I see the following code that looks similar to what I changed within userjoin.php:

$data['extra'] = isset($_POST['extra']) ? $format->inputSQL($_POST['extra'], 'string') : '';
__________________
Many Thanks,

Nagrap2

Developer Version 4.1
nagrap2 is offline   Reply With Quote
Old 02-16-2009, 12:27 PM   #9
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,776
Rep Power: 110
Eric Barnes is a jewel in the rough
Default

Yes you would just edit that line:
$data['extra'] = isset($_POST['extra']) ? $format->inputSQL($_POST['extra'], 'string') : '';

Becomes:
$myextra = $_POST['BirthDays'] . $_POST['BirthMonths'] . $_POST['BirthYears'];
$data['extra'] = isset($myextra) ? $format->inputSQL($myextra, 'string') : '';
__________________
Eric Barnes
68 Classifieds Developer
Please do not send me a private message asking for support. Instead use these open forums or our ticket system.

Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 02-16-2009, 02:21 PM   #10
Member
 
Join Date: Aug 2008
Posts: 63
Rep Power: 4
nagrap2 is on a distinguished road
Default

Thanks Eric that worked perfect !!!!!
__________________
Many Thanks,

Nagrap2

Developer Version 4.1
nagrap2 is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy/Past website URL from the ad HorseOptions HTML, CSS, and Design Help 3 12-04-2008 05:35 PM
Run 2nd copy 68C on local machine.... RandyB v4 Questions & Support 3 11-25-2008 02:24 PM
Copy listings euroclassifieds v4 Questions & Support 1 07-05-2008 07:50 AM
2nd copy of 68 Classifieds seymourjames Pre Sales Questions 3 05-15-2008 10:57 AM


All times are GMT -4. The time now is 06:48 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0