Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datepicker html issue, no solution? 1

Status
Not open for further replies.

zinja

MIS
Nov 14, 2002
149
US
Ok. I have tried about 20 different methods, but can't seem to get the datepicker button to be at the end of the text input box. What I have done is to implement the datepicker class from Stefan Gabos (great class). It works just fine (I just made a function and call the function when needed. The problem is with the layout of the html form that it is a part of. I want the button to be to the right of the text input box. I have included the current code for the form, the form function, and the showdate function (datepicker). Any help would be greatly appreciated. I have about pulled my hair out on this.

Code:
// form

     echo userform2 ('<b>Expiration Date (YYYY-MM-DD)</b>', '<input type="text" size="25" id="date_expired" name="date_expired" value="' . $form['date_expired'] . '" maxlength="10">', showdate("date_expired") );

Code:
// showdate function

function showdate($dategiven)
{
  // include the class
    require "./datepicker/class.datepicker.php";

    // instantiate the object
    $dp=new datepicker();

?>
<input type="button" value="Select" onclick="<?=$dp->show($dategiven)?>">
<?
}

Code:
// userform2 function

function userform2 ( $name, $field, $dateformat, $required = '' )

 {

  $output = '

   <tr>
    <td width="30%" align="right" valign="top">
     ' . $name;

   // If the field is required we add the red asterisk
   if ($required == '1')
    $output.= ' <span class="warning">*</span> ';

   $output.= '
    </td>
    <td width="70%" align="left" valign="top">
     ' . $field . '
    ' . $dateformat . '
	</tr>
	</td>
  	';
  return $output;

 }

Thanks in advance.

LJ

LJ Wilson

My personal saying - Just remember, it can always get worse, and usually will.
 
No advice?


LJ Wilson

My personal saying - Just remember, it can always get worse, and usually will.
 
where is the button created?

and why in this code:
Code:
 $output.= '
    </td>
    <td width="70%" align="left" valign="top">
     ' . $field . '
    ' . $dateformat . '
    [red]</tr>
    </td>[/red]
      ';
are you outputting a row terminator before a cell terminator? that might be your problem as you would be forcing the output down to the next line before you want.
 
The button is created in the showdate function and displayed on the form that contains the echouserform function. It is now being displayed above and to the left of the first textbox (the one that contains the call to the showdate function).

I have tried several things. Is it because I am calling it from a function instead of drawing it as part of the echouserform function?


LJ Wilson

My personal saying - Just remember, it can always get worse, and usually will.
 
I don't know. have you tried the change that i outlined in red?

can you post the code that produces the button (the html within the php) and a snip of the the html actually produced for the browser (a view source).
 
Thanks for the super fast response. Here is a snippet of the generated html from the form page.

Code:
    <form action="[URL unfurl="true"]http://localhost/armls/adduserlistings.php"[/URL] method="POST">
     <table width="100%" cellpadding="5" cellspacing="0" border="0">
     .<input type="button" value="Select" onclick="javascript:var cw = null; cw = window.open('/armls/datepicker/includes/datepicker.php?preselectedDate=&selectableDatesRange=N%3B&selectableYearsRange=a%3A0%3A%7B%7D&selectableTimesRange=a%3A0%3A%7B%7D&enableTimePicker=&month=&year=&hour=&minute=&controlName=date_expired&dateFormat=Y-m-d&firstDayOfWeek=0&language=english&template=default','datePicker','width=250,height=300,scrollbars=no,toolbar=no,menubar=no,location=no,alwaysraised=yes,modal=yes'); if (window.focus) { cw.focus() } return false">


   <tr>
    <td width="30%" align="right" valign="top">
     <b>Expiration Date (YYYY-MM-DD)</b>
    </td>

    <td width="70%" align="left" valign="top">
     <input type="text" size="25" id="date_expired" name="date_expired" value="" maxlength="10">
    
	</td>
  	</tr>


Here is where the html for the button is made (in the showdate function)

Code:
<input type="button" value="Select" onclick="<?=$dp->show($dategiven)?>">

Thanks!



LJ Wilson

My personal saying - Just remember, it can always get worse, and usually will.
 
I did try the change you suggested, it didn't make a difference. The html source I posted is after that change.


LJ Wilson

My personal saying - Just remember, it can always get worse, and usually will.
 
i'm being dim. you had given me the information above but i had not fully read it. your problem is in the function called showdate(). here is an amended version that will work

Code:
function showdate($dategiven)
{
  // include the class
    require "./datepicker/class.datepicker.php";

    // instantiate the object
    $dp=new datepicker();
[red]
    return '
<input type="button" value="Select" onclick="'.$dp->show($dategiven).'">';[/red]
}

you will also need to change the userform2 function as i set out above.
 
That works perfectly. It is displayed correctly now, thank you so much for the help (I am still very new to PHP). I have one more question.

What would cause the script to allow the change from month to month (selecting a different month on the popup calendar) on a Windows machine and not on a Linux machine. Everything else seems to work just fine. The calendar displays and defaults to the current month. I thought maybe permissions were causing the issue, but I have tried changing the whole datepicker directory to 777 (in a test environment - changed back quickly), but that didn't help. I realize you didn't write the script, just wondering if you have any ideas?

Thanks again.


LJ Wilson

My personal saying - Just remember, it can always get worse, and usually will.
 
it won't be anything windows vs linux. it will be more the compatibility of certain browsers with the javascript generated by the script. you'd have to take a look at the generated javascript or the js within an include file and do some debugging to see where the browsers in question are complaining. the chaps in the js forum will be able to help
 
I think my post was confusing. On my development server (Windows), the script works fine (allows month to month changing). On my production server (Linux environment), the script doesn't allow month to month transitioning. Same browser, same computer, just different php environments.


LJ Wilson

My personal saying - Just remember, it can always get worse, and usually will.
 
i'm confused too. where is the month changed? in php or in javascript? it is so much more likely to be a configuration issue between the two servers.
 
It is changed in javascript. I guess I should change this over to that forum. I will try to troubleshoot some more and see what I can find out. Since the only difference was the server environment, I suspected a PHP issue.

LJ Wilson

My personal saying - Just remember, it can always get worse, and usually will.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top