Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 08-24-2010, 12:38 PM passing in values
Extreme Talker

Posts: 173
Trades: 0
Can someone have a look at this and confirm if have this right or not. I can say it is not working the way I expected so I might have the formatting incorrect.

I am trying to pass in the value from php:
$row['rdd']= '2010-04-22'


Code:
?>
    <script>
     var check_date=<?php echo $row['rdd']; ?>;
     if (check_date==null){
      DateInput('ship_date');
      } 
     else{ 
      DateInput('ship_date', false, 'YYYY-MM-DD',check_date);
     }
    </script>
<?php
dgkindy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-24-2010, 12:50 PM Re: passing in values
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
the way you pass it would mean in javascript the variable will be a string object not a date object


Code:
var check_date= new date(<?php echo str_replace($row['rdd'],'-',','); ?>;
looks about right
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-24-2010, 03:56 PM Re: passing in values
Extreme Talker

Posts: 173
Trades: 0
Okay, so I made the correction but still not getting the desired result. It appears to be jumping right past the if statement. I have tried to print the check_date value to confirm that it is being received but failed to get to work as well.


Also, why did you indicate that the date formate need to be changed? I had a quick look to try and understand a reason, but from what I can the format was alright??

Quote:
'<li><label for="aoa">AOA:</label>';
echo $row['rdd'];
?>
<script>
var check_date= new date(<?php echo str_replace($row['rdd'],'-',','); ?>);
document.write(check_date);
if (check_date==null){
DateInput('ship_date');
}
else{
DateInput('ship_date', false, 'YYYY-MM-DD',check_date);
}
</script>
<?php
echo '</li>'.
dgkindy is offline
Reply With Quote
View Public Profile
 
Old 08-25-2010, 05:19 PM Re: passing in values
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
In javascript the DD MM YY parameters are separated by commas (,) and your post indicated that your date string was separated br dashes (-)
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-03-2010, 09:54 PM Re: passing in values
Extreme Talker

Posts: 173
Trades: 0
Okay, so what I figured out is that I am not passing a date but a string.

As for the IS NULL, that I am not sure as it seems backwards to me but it is working now.

Code:
    <script>
     var check_date='<?php echo $row['ship_date']; ?>';
     if (!check_date){
      DateInput('ship_date')
     } 
     else{ 
      DateInput('ship_date', false, 'YYYY-MM-DD',check_date)
     }
    </script>
dgkindy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to passing in values
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15233 seconds with 12 queries