Gotcha...thanks for that tip.  I'm glad I caught this issue when working
with my
sample data (the column type is varchar in MySQL) instead of after this was
in
production.  I surely wish json would just leave the data alone, but your
solution
is easy to implement and doesn't require altering the data in the db.

Much appreciated!

On Mon, Jun 22, 2009 at 12:52 AM, Azadi Saryev <[email protected]> wrote:

>
> no, the INSERT/UPDATE and simple passing of form value to cfc via ajax
> call works just fine with a leading 0 in the form field's value (as long
> as datatype of the column is text-based; otherwise it's your db that may
> strip out leading 0). so you do not need to add anything to the value of
> form field/variable when you are doing insert/update via ajax call or
> just passing data to your function (i.e. for checking user password).
>
> it's when you are returning a SELECT query data via ajax call the
> leading 0 will be stripped from column value when it is json-encoded. so
> what you can do to avoid this is, in your query sql, concatenate
> space/underscore with the value of column that may have a leading 0
> (i.e. SELECT ..., CONCAT(' ', somecolumn) AS somecolumn, ...).
>
> adding space is easier because it's easier to trim it - you can just use
> $.trim(string) jquery function before you output the data to screen.
>
>
> Azadi Saryev
> Sabai-dee.com
> http://www.sabai-dee.com/
>
>
>  On 22/06/2009 10:05, Rick Faircloth wrote:
> > So, you just concatenate the underscore to the data and then strip it out
> > when you retrieve it from the db?
> >
> > E.g., if I were inserting 0123 into the db, I would concatenate an
> > underscore
> > to make it _0123, then when I pull the data out of the db just strip off
> the
> > underscore?
> >
> > On Sun, Jun 21, 2009 at 9:08 PM, Azadi Saryev <[email protected]>
> wrote:
> >
> >> i suspect you are talking about values returned by an ajax call? because
> >> js has no problem with leading 0... but ajax does.
> >>
> >> what i usually do when returning values from db which may potetnially
> >> have a leading 0, is prepend a space to the value in the query using
> >> conacatenate() db function.
> >>
> >> Azadi Saryev
> >> Sabai-dee.com
> >> http://www.sabai-dee.com/
> >>
> >>
> >>  On 22/06/2009 01:21, Rick Faircloth wrote:
> >>> Got any ideas on how to cause a javascript variable to retain a leading
> >>> zero?
> >>> If I have a user with a password with a leading 0, it drops the zero.
>  I
> >>> need to retain it.
> >>>
> >>> On Sun, Jun 21, 2009 at 12:09 PM, Azadi Saryev <[email protected]>
> >> wrote:
> >>>> well, anything in the url can be accessed easily by cf, as you no
> doubt
> >>>> know :)
> >>>>
> >>>> you can also access it using js, though it's not anywhere near the
> cf's
> >>>> one-liner:
> >>>> http://www.netlobo.com/url_query_string_javascript.html
> >>>>
> >>>>
> >>>> Azadi Saryev
> >>>> Sabai-dee.com
> >>>> http://www.sabai-dee.com/
> >>>>
> >>>>
> >>>>  On 21/06/2009 22:31, Rick Faircloth wrote:
> >>>>> Thanks, Azadi!
> >>>>>
> >>>>> It's a little confusing knowing which variables can be treated as CF
> >>>>> variables and which
> >>>>> can only be handled as jQuery variables!
> >>>>>
> >>>>> Making good progress now!
> >>>>>
> >>>>> Rick
> >>>>>
> >>>>> On Sun, Jun 21, 2009 at 10:59 AM, Azadi Saryev <[email protected]>
> >>>> wrote:
> >>>>>> do what you do for your dsn var - use <cfoutput>!
> >>>>>>
> >>>>>> var values = {
> >>>>>>  dsn: '<cfoutput>#application.dsn</cfoutput>',
> >>>>>>  managerID:  <cfoutput>#url.managerId#</cfoutput>
> >>>>>> };
> >>>>>> console.log(values.managerID);
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> Azadi Saryev
> >>>>>> Sabai-dee.com
> >>>>>> http://www.sabai-dee.com/
> >>>>>>
> >>>>>>
> >>>>>>  On 21/06/2009 21:23, Rick Faircloth wrote:
> >>>>>>> Thanks, Azadi...that did the trick...guess i didn't try that
> option.
> >>>>>>>
> >>>>>>> I can get the variable in to the page that is inside the thickbox,
> >>>>>>> because I can run� <cfoutput>managerID = #url.managerID#</cfoutput>
> >>>>>>> and get managerID = 1, however I can't find a way to make use of
> the
> >>>>>> variable
> >>>>>>> in jQuery.
> >>>>>>>
> >>>>>>> When the page being inserted into the modal window is called, I
> have
> >> a
> >>>>>>> jQuery function
> >>>>>>> that runs to retrieve the data from a component method for the
> record
> >>>>>>> matching the managerID.
> >>>>>>> But in the function, I keep getting "managerID is undefined".
>  Here's
> >>>>>>> the first part of the function:
> >>>>>>>
> >>>>>>> $(document).ready(function(url.managerID) {
> >>>>>>>
> >>>>>>>      var values  =  {  dsn:
> >>>>>>  '<cfoutput>#application.dsn</cfoutput>',
> >>>>>>>                             managerID:  url.managerId  };
> >>>>>>>
> >>>>>>>      console.log(managerID);
> >>>>>>>      alert('managerID = ' + managerID + 'url.managerID = '
> >>>>>> +url.managerID);
> >>>>>>> i've tried various versions of the above code to try to get the
> >>>>>>> managerID in jQuery,
> >>>>>>> but nothing has worked so far.
> >>>>>>>
> >>>>>>> How can I change this code to retrieve the managerID variable being
> >>>>>>> sent in the URL?
> >>>>>>>
> >>>>>>> Thanks for your help!
> >>>>>>>
> >>>>>>> Rick
> >>>>>>>
> >>>>>>> On Sun, Jun 21, 2009 at 8:41 AM, Azadi Saryev <[email protected]
> >
> >>>>>> wrote:
> >>>>>>>> the correct way would be:
> >>>>>>>>
> >>>>>>>> tb_show("EditSiteManager",
> >>>>>>>>
> >>
> "../modals/siteManagerEditForm.cfm?height=425&width=500&modal=true&managerID="+thisID,
> >>>>>>>> false);
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> Azadi Saryev
> >>>>>>>> Sabai-dee.com
> >>>>>>>> http://www.sabai-dee.com/
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> On 21/06/2009 18:31, Rick Faircloth wrote:
> >>>>>>>>> tb_show("EditSiteManager",
> >>>>>>>>>
> >>
> "../modals/siteManagerEditForm.cfm?height=425&width=500&modal=true&managerID=thisID",
> >>>>>>>>> false);
> >>>
> >>
> >
> >
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323772
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to