[RESOLVED] Show YYYY-MM-DD in show_search_form.inc.php

Everything related to Hesk - helpdesk software

Moderator: mkoch227

Post Reply
Raven
Posts: 172
Joined: Sat Jun 20, 2009 12:39 am

[RESOLVED] Show YYYY-MM-DD in show_search_form.inc.php

Post by Raven »

Hi, within the admin section I need to have both of the following sections of code together in the same part so that when you click the textfield it not only selects the correct radio button but also clears the textfield of the default value -

This is what I have at the moment

Code: Select all

<input type="text" name="dt" value="<?php echo $value; ?>" size="35" maxlength="10" onfocus="Javascript:document.findby.what[2].checked=true;" />
But I need to have this (which is the original code):

Code: Select all

onfocus="Javascript:document.findby.what[2].checked=true;"
to also work with this (which shows yyyy-mm-dd as the default value until the user clicks the textfield then it removes it):

Code: Select all

onfocus="if (this.value=='<?php echo $value; ?>'){this.value='';};return false;" onblur="if (this.value==''){this.value='<?php echo $value; ?>';return false;}"
At the moment I can only use one or the other but the final result needs to be this

Code: Select all

<input type="text" name="dt" value="<?php echo $value; ?>" size="35" maxlength="10" onfocus="Javascript:document.findby.what[2].checked=true;" />
and this

Code: Select all

<input type="text" name="dt" value="<?php echo $value; ?>" size="35" maxlength="10" onfocus="Javascript:document.findby.what[2].checked=true;" onfocus="if (this.value=='<?php echo $value; ?>'){this.value='';};return false;" onblur="if (this.value==''){this.value='<?php echo $value; ?>';return false;}" />
combined if that makes sense....

Please, any help would be great.
Last edited by Raven on Sat Oct 17, 2009 6:57 pm, edited 1 time in total.
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

You can't have two onfocus for the same element. Have you tried just combining the code in one onfocus, like:

Code: Select all

onfocus="Javascript:document.findby.what[2].checked=true; if (this.value=='<?php echo $value; ?>'){this.value='';};return false;" 
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Raven
Posts: 172
Joined: Sat Jun 20, 2009 12:39 am

Post by Raven »

Thats almost exactly what I need hehe - is there any way to bring back YYYY-MM-DD when the user clicks out of the textfield unless they have actually entered a date?

P.S.
God I wish I could code correctly lol - it is so frustrating knowing what you want but not quite knowing the correct code to use....
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Not sure if this is what you mean, but change the <?php echo $value; ?> in the onfocus and onblur to YYYY-MM-DD
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Raven
Posts: 172
Joined: Sat Jun 20, 2009 12:39 am

Post by Raven »

Forgive me if I'm wrong with this but if I replace <?php echo $value; ?> with YYYY-MM-DD then when I click out/away from the textfield won't it just replace whatever I've just typed in?

I'm not in front of my Web Server at the moment but I'll test it when I get back home and let you know how it turns out ;)

Thanks again for your help Klemen 8)
Raven
Posts: 172
Joined: Sat Jun 20, 2009 12:39 am

Post by Raven »

Hi, this is what I ended up with and it works just as I needed ;)

Code: Select all

		<tr>
		<td valign="top"><label><input type="radio" name="what" value="dt"
        <?php
        $value='YYYY-MM-DD';
        if ($what == 'dt')
        {
	        echo 'checked="checked"';
			if (isset($_GET['dt']))
	        {
		        $value = hesk_input($_GET['dt']);
	        }
        }
        ?> /> <?php echo $hesklang['date_posted']; ?></label>: &nbsp; </td>
		<td><input type="text" name="dt" value="<?php echo $value; ?>" size="35" maxlength="10" onfocus="Javascript:document.findby.what[2].checked=true; if (this.value=='<?php echo $value; ?>'){this.value='';};return false;" onblur="if (this.value==''){this.value='<?php echo $value; ?>';return false;}" /></td>
		</tr>
Now the field shows YYYY-MM-DD all the time. When I click it the YYYY-MM-DD is cleared, and if I type nothing and click away/on something else the YYYY-MM-DD is re-entered in to the field.

Finally, if I actually type a date and click away it stays in the box just as it should until I click on the Find Ticket button :)

Thank you again for your help - I have now learnt how to add multiple onfocus= / onblur= etc... items to a link :)
Post Reply