This topic is locked

onfocus and onblur

11/9/2009 3:27:25 AM
PHPRunner General questions
D
danaci author

<html>

<head>

<script type="text/javascript">

function on_focus(deger) { document.getElementById(deger).style.backgroundColor = 'yellow'; }

function on_blur(deger) { document.getElementById(deger).style.backgroundColor = '#f0f0f0'; }
</script>

</head>

<body>

<table><tr><td>

Adı : </td>

<td><input id="Text1" type="text" onfocus='on_focus("Text1")' onblur='on_blur("Text1")' style="background-color: #f0f0f0; border: solid 1px #777;" />

</td></tr><tr><td>

Soyadı : </td>

<td><input id="Text2" type="text" onfocus='on_focus("Text2")' onblur='on_blur("Text2")' style="background-color: #f0f0f0; border: solid 1px #777;"/>

</td></tr><tr><td>

E-Posta : </td>

<td><input id="Text3" type="text" onfocus='on_focus("Text3")' onblur='on_blur("Text3")' style="background-color: #f0f0f0; border: solid 1px #777;"/>

</td></tr></table>

</body></html>
is it possible this code to phpr?
my fieldname is {$fieldname}.

onfocus='on_focus("Text1")' onblur='on_blur("Text1")' style="background-color: #f0f0f0; border: solid 1px #777;"

onblur='on_blur("Text3")' style="background-color: #f0f0f0; border: solid 1px #777;"

Where should I put this code?

thnx.

J
Jane 11/9/2009

Hi,
here is just a sample:

<script>

document.forms.editform.value_FieldName.onfocus = function()

{

on_focus("Text1");

}

</script>
D
danaci author 11/9/2009



Hi,
here is just a sample:

<script>

document.forms.editform.value_FieldName.onfocus = function()

{

on_focus("Text1");

}

</script>



The way you apologize as much as I could not solve the problem.

D
danaci author 11/9/2009



Hi,
here is just a sample:

<script>

document.forms.editform.value_FieldName.onfocus = function()

{

on_focus("Text1");

}

</script>



dear jane,

my phpr files and

my fields sno={$sno_editcontrol},ad={$ad_editcontrol},adres={$adres_editcontrol}

I added script to head
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD><TITLE>Ana</TITLE>
<script type=text/javascript>

function on_focus(deger) { document.getElementById(deger).style.backgroundColor = 'yellow'; }

function on_blur(deger) { document.getElementById(deger).style.backgroundColor = '#f0f0f0'; }
</SCRIPT>
<link REL="stylesheet" href="include/style.css" type="text/css"><!--[if IE]><link REL="stylesheet" href="include/styleIE.css" type="text/css"><![endif]-->

<STYLE>

..

..

</STYLE>
<META content="MSHTML 6.00.6000.20815" name=GENERATOR></HEAD>

<BODY>
<script>

document.forms.editform.value_FieldName.onfocus = function()

{

on_focus({$ad_editcontrol});

}

</SCRIPT
{$header}{BEGIN body}
<TABLE id="center_block{$id}" cellSpacing=0 cellPadding=0 align=center border=0>

<TBODY>

<TR>

<TD>{BEGIN flybody}<B class=xtop><B class=xb1b></B><B

class=xb2b></B><B class=xb3b></B><B class=xb4b></B></B>

<DIV class=upeditmenu id="header_block{$id}">Ana, Add new record

</DIV>

<DIV class=main_table_border2

style="BORDER-RIGHT: #516c81 1px solid; BORDER-TOP: #516c81 1px solid; BORDER-LEFT: #516c81 1px solid; BORDER-BOTTOM: #516c81 1px solid">

<TABLE class=main_table_border cellSpacing=0 cellPadding=0 align=center

border=0>

{BEGIN message_block}<DIV class=downedit id="message_block{$id}">{$message}</DIV>{END message_block}

<TBODY>

{BEGIN sno_fieldblock}<TR style="PADDING-RIGHT: 3px; PADDING-LEFT: 3px; PADDING-BOTTOM: 3px; PADDING-TOP: 3px">

<TD class=editshade_b style="PADDING-LEFT: 15px" width=150>Sno</TD>

<TD class=editshadelb style="PADDING-LEFT: 10px" width=250>{$snoeditcontrol}</TD></TR>{END sno_fieldblock}

{BEGIN ad_fieldblock}<TR style="PADDING-RIGHT: 3px; PADDING-LEFT: 3px; PADDING-BOTTOM: 3px; PADDING-TOP: 3px">

<TD class=editshade_b style="PADDING-LEFT: 15px" width=150>Ad</TD>

<TD class=editshadelb style="PADDING-LEFT: 10px" width=250>{$adeditcontrol}</TD></TR>{END ad_fieldblock}

{BEGIN adres_fieldblock}<TR style="PADDING-RIGHT: 3px; PADDING-LEFT: 3px; PADDING-BOTTOM: 3px; PADDING-TOP: 3px">

<TD class=editshade_b style="PADDING-LEFT: 15px" width=150>Adres</TD>

<TD class=editshadelb style="PADDING-LEFT: 10px" width=250>{$adreseditcontrol}</TD></TR>{END adres_fieldblock}</TBODY></TABLE>

<DIV class=downedit id="buttons_block{$id}">

<DIV id="required_block{$id}"><IMG src="images/icon_required.gif"> -

Required field</DIV>{BEGIN save_button}<SPAN class=buttonborder><INPUT class=button type=submit value=Save name=submit1></SPAN>{END save_button}{BEGIN reset_button}<SPAN class=buttonborder><INPUT class=button type=reset value=Reset></SPAN>{END reset_button}{BEGIN cancel_button}<SPAN class=buttonborder><INPUT class=button type=button value=Cancel {$cancelbutton_attrs}></SPAN>{END cancel_button}{BEGIN back_button}<SPAN class=buttonborder><INPUT class=button type=button value="Back to list" {$backbutton_attrs}></SPAN>{END back_button}</DIV></DIV><B

class=xbottom><B class=xb4b></B><B class=xb3b></B><B class=xb2b></B><B

class=xb1b></B></B>{END flybody}</TD></TR></TBODY></TABLE>{$footer}{END body}

</BODY></HTML
The way you apologize as much as I could not solve the problem.

This gives a solution within you?

Head into your code block into the block or body Should I include?

J
Jane 11/10/2009

Hi,
getElementByID method won't work for your fields.

Here is a sample:

document.forms.editform.value_FieldName.style.backgroundColor=...



Also this code should be executed at the end of the page, not just after HEAD section.