Connecting Tech Pros Worldwide Forums | Help | Site Map

function EnablerInput() not working

guillaume
Guest
 
Posts: n/a
#1: Jul 20 '05
hello from france,

I want to edit a list of customers dynamically and
each row contains an input text with the name of customer and link to update the name the link calls the javascript function "enablerInput()" to change the input's property from disabled to enable.

--------------------------------------------------------------------------------

the HTML part is a table and i add rows with SQL query ... here is the code
$query = "SELECT * FROM $table";

$res = mysql_query($query);

// tant qu'il y a des fiches

while ($val = mysql_fetch_array($res))

{

$ident = $val["Id_client"]

?>

<tr>

<form name="tablo_client">

<td><input type="text" disabled id="<? $ident; ?>" value='<? echo $val["nom"]; ?>'></td> //function EnablerInput() has to change the property disabled

<td align="center"><a href="javascript:supprimer(); id='<? echo $id; ?>' ">supprimer</a></td>

<td><a href='javascript:EnablerInput(<? $ident; ?>);'>modifier</a></td> //the link to call the function below


</tr>


--------------------------------------------------------------------------------


the function is simple .... but doen't work

function EnablerInput(ident)

{

document.tablo_client.ident.disabled=false; // error message ; document.tablo_client.ident is not an object or is null

}

maybe should i create one form for each row ?



Vicomte De Valmont
Guest
 
Posts: n/a
#2: Jul 20 '05

re: function EnablerInput() not working


Hi

well assuming that id="<? $ident; ?>" would relinquish as name ident (which
I'm not sure, glancing quickly your php it seemed a variable which could
accept whatever value an user insert: $ident = $val["Id_client"]: it MUSt
relinquish "ident" if you want a command in JAVASCRIpt like
document.tablo_client.ident locate a NAME="ident" within a form whose name
on its own turn is "tablo_client") the main issue, or maybe just the most
apparent one seems: not id= but NAME=
Try that for now, then we'll see the rest.
ciao
Alberto
http://www.unitedscripters.com/




"guillaume" <pguillaume1@9online.fr> ha scritto nel messaggio
news:bnh313$hc4$1@aphrodite.grec.isp.9tel.net...
hello from france,

I want to edit a list of customers dynamically and
each row contains an input text with the name of customer and link to update
the name the link calls the javascript function "enablerInput()" to change
the input's property from disabled to enable.

----------------------------------------------------------------------------
----

the HTML part is a table and i add rows with SQL query ... here is the code
$query = "SELECT * FROM $table";

$res = mysql_query($query);

// tant qu'il y a des fiches

while ($val = mysql_fetch_array($res))

{

$ident = $val["Id_client"]

?>

<tr>

<form name="tablo_client">

<td><input type="text" disabled id="<? $ident; ?>" value='<? echo
$val["nom"]; ?>'></td> //function EnablerInput() has to
change the property disabled

<td align="center"><a href="javascript:supprimer(); id='<? echo $id; ?>'
">supprimer</a></td>

<td><a href='javascript:EnablerInput(<? $ident; ?>);'>modifier</a></td>
//the link to call the function below


</tr>


----------------------------------------------------------------------------
----


the function is simple .... but doen't work

function EnablerInput(ident)

{

document.tablo_client.ident.disabled=false; // error
message ; document.tablo_client.ident is not an object or is null

}

maybe should i create one form for each row ?



guillaume
Guest
 
Posts: n/a
#3: Jul 20 '05

re: function EnablerInput() not working


thanks for your help , i have changed id---> name but it doesn't work
:-( bye

"Vicomte De Valmont" <NOSPAM@hotmail.com> a écrit dans le message de news:
bnh4cd$1dd$1@lacerta.tiscalinet.it...[color=blue]
> Hi
>
> well assuming that id="<? $ident; ?>" would relinquish as name ident[/color]
(which[color=blue]
> I'm not sure, glancing quickly your php it seemed a variable which could
> accept whatever value an user insert: $ident = $val["Id_client"]: it MUSt
> relinquish "ident" if you want a command in JAVASCRIpt like
> document.tablo_client.ident locate a NAME="ident" within a form whose name
> on its own turn is "tablo_client") the main issue, or maybe just the most
> apparent one seems: not id= but NAME=
> Try that for now, then we'll see the rest.
> ciao
> Alberto
> http://www.unitedscripters.com/
>
>
>
>
> "guillaume" <pguillaume1@9online.fr> ha scritto nel messaggio
> news:bnh313$hc4$1@aphrodite.grec.isp.9tel.net...
> hello from france,
>
> I want to edit a list of customers dynamically and
> each row contains an input text with the name of customer and link to[/color]
update[color=blue]
> the name the link calls the javascript function "enablerInput()" to[/color]
change[color=blue]
> the input's property from disabled to enable.
>
> --------------------------------------------------------------------------[/color]
--[color=blue]
> ----
>
> the HTML part is a table and i add rows with SQL query ... here is the[/color]
code[color=blue]
> $query = "SELECT * FROM $table";
>
> $res = mysql_query($query);
>
> // tant qu'il y a des fiches
>
> while ($val = mysql_fetch_array($res))
>
> {
>
> $ident = $val["Id_client"]
>
> ?>
>
> <tr>
>
> <form name="tablo_client">
>
> <td><input type="text" disabled id="<? $ident; ?>" value='<? echo
> $val["nom"]; ?>'></td> //function EnablerInput() has to
> change the property disabled
>
> <td align="center"><a href="javascript:supprimer(); id='<? echo $id; ?>'
> ">supprimer</a></td>
>
> <td><a href='javascript:EnablerInput(<? $ident; ?>);'>modifier</a></td>
> //the link to call the function below
>
>
> </tr>
>
>
> --------------------------------------------------------------------------[/color]
--[color=blue]
> ----
>
>
> the function is simple .... but doen't work
>
> function EnablerInput(ident)
>
> {
>
> document.tablo_client.ident.disabled=false; // error
> message ; document.tablo_client.ident is not an object or is null
>
> }
>
> maybe should i create one form for each row ?
>
>
>[/color]


Vicomte De Valmont
Guest
 
Posts: n/a
#4: Jul 20 '05

re: function EnablerInput() not working


Ok, I detail it to you:
1)
The error you report is:
document.tablo_client.ident is not an object
Now: does $ident = $val["Id_client"]: return a string which is exactly
"ident" - do not confuse $ident with "ident": $ident is a variable name,
"ident" a value which has to be assigned to the name of the input field.
That is
if $ident = $val["Id_client"]:
then
$val["Id_client"] MUST return String: "ident"

THEN:
2)
you say:
input type="text" disabled NAME="<? $ident; ?>"
AND you say:
a href='javascript:EnablerInput(<? $ident; ?>);
this cannot be: IF $ident returns "ident" as I do hope (!!), you're sayng
this:
name="ident"
AND
a href='javascript:EnablerInput(ident)
that cannot work: ident is not in between quotes, so it is assumed as a
variable name which in your script is not defined.
perhaps you meant:
a href='javascript:EnablerInput("\"<? $ident; ?>\"");

THEN:
3)
a href='javascript:EnablerInput("\"<? $ident; ?>\"");
has no meaning, even as
a href='javascript:EnablerInput(<? $ident; ?>);
IF the body of your function then says:
function EnablerInput(ident){document.tablo_client.ident.di sabled=false;}
In fact, if ident is a string it would turn into:
document.tablo_client."ident".disabled
which causes errors.
If ident is an object (which is not) it would return
document.tablo_client.SomeObject.disabled
which is not what you meant.
THUS: be sure the value you pass is a STRING, in between quotes, then
rearrange your code into:
document.tablo_client.[ident].disabled
thus you will exploiti the associative array capabilities of the object.

But foremost: are you sure $ident returns "ident", a STRING?

PS also, your php says:
while ($val = mysql_fetch_array($res))

{

$ident = $val["Id_client"]

/*no closing } bracket. Perhaps you omitted it but was in your original
code*/


ciao
Alberto Vallini
http://www.unitedscripters.com/


"guillaume" <pguillaume1@9online.fr> ha scritto nel messaggio
news:bnh7va$7pd$1@apollon.grec.isp.9tel.net...[color=blue]
> thanks for your help , i have changed id---> name but it doesn't work
> :-( bye
>
> "Vicomte De Valmont" <NOSPAM@hotmail.com> a écrit dans le message de news:
> bnh4cd$1dd$1@lacerta.tiscalinet.it...[color=green]
> > Hi
> >
> > well assuming that id="<? $ident; ?>" would relinquish as name ident[/color]
> (which[color=green]
> > I'm not sure, glancing quickly your php it seemed a variable which could
> > accept whatever value an user insert: $ident = $val["Id_client"]: it[/color][/color]
MUSt[color=blue][color=green]
> > relinquish "ident" if you want a command in JAVASCRIpt like
> > document.tablo_client.ident locate a NAME="ident" within a form whose[/color][/color]
name[color=blue][color=green]
> > on its own turn is "tablo_client") the main issue, or maybe just the[/color][/color]
most[color=blue][color=green]
> > apparent one seems: not id= but NAME=
> > Try that for now, then we'll see the rest.
> > ciao
> > Alberto
> > http://www.unitedscripters.com/
> >
> >
> >
> >
> > "guillaume" <pguillaume1@9online.fr> ha scritto nel messaggio
> > news:bnh313$hc4$1@aphrodite.grec.isp.9tel.net...
> > hello from france,
> >
> > I want to edit a list of customers dynamically and
> > each row contains an input text with the name of customer and link to[/color]
> update[color=green]
> > the name the link calls the javascript function "enablerInput()" to[/color]
> change[color=green]
> > the input's property from disabled to enable.
> >[/color]
>
> --------------------------------------------------------------------------
> --[color=green]
> > ----
> >
> > the HTML part is a table and i add rows with SQL query ... here is the[/color]
> code[color=green]
> > $query = "SELECT * FROM $table";
> >
> > $res = mysql_query($query);
> >
> > // tant qu'il y a des fiches
> >
> > while ($val = mysql_fetch_array($res))
> >
> > {
> >
> > $ident = $val["Id_client"]
> >
> > ?>
> >
> > <tr>
> >
> > <form name="tablo_client">
> >
> > <td><input type="text" disabled id="<? $ident; ?>" value='<? echo
> > $val["nom"]; ?>'></td> //function EnablerInput() has to
> > change the property disabled
> >
> > <td align="center"><a href="javascript:supprimer(); id='<? echo $id; ?>'
> > ">supprimer</a></td>
> >
> > <td><a href='javascript:EnablerInput(<? $ident; ?>);'>modifier</a></td>
> > //the link to call the function below
> >
> >
> > </tr>
> >
> >[/color]
>
> --------------------------------------------------------------------------
> --[color=green]
> > ----
> >
> >
> > the function is simple .... but doen't work
> >
> > function EnablerInput(ident)
> >
> > {
> >
> > document.tablo_client.ident.disabled=false; //[/color][/color]
error[color=blue][color=green]
> > message ; document.tablo_client.ident is not an object or is null
> >
> > }
> >
> > maybe should i create one form for each row ?
> >
> >
> >[/color]
>
>[/color]


Vicomte De Valmont
Guest
 
Posts: n/a
#5: Jul 20 '05

re: function EnablerInput() not working


The following statemnent (#2) by me is not really precise. yet before making
further guesswork or correcting it, let me insist: $ident must return a
STRING saying "ident". If we are not sure about it we can just speculate you
see. let us know.
Then in your function:
document.tablo_client.[ident].disabled=false;
use the associative array prerogatives.

ciao

[color=blue]
> 2)
> you say:
> input type="text" disabled NAME="<? $ident; ?>"
> AND you say:
> a href='javascript:EnablerInput(<? $ident; ?>);
> this cannot be: IF $ident returns "ident" as I do hope (!!), you're sayng
> this:
> name="ident"
> AND
> a href='javascript:EnablerInput(ident)
> that cannot work: ident is not in between quotes, so it is assumed as a
> variable name which in your script is not defined.
> perhaps you meant:
> a href='javascript:EnablerInput("\"<? $ident; ?>\"");
>[/color]


Vicomte De Valmont
Guest
 
Posts: n/a
#6: Jul 20 '05

re: function EnablerInput() not working


Jesus Christ, I meant:
document.tablo_client[ident].disabled=false;
no dot after client. Sorry but we're lending help a bit on the run, ciao
Alberto


guillaume
Guest
 
Posts: n/a
#7: Jul 20 '05

re: function EnablerInput() not working


thanks for your help again,
we have $ident = val [Id_client]
val["Id_client"] is the primary key, Id type integer i retrieved from
the database
but i used the debug Machine with a stop just after $ident to control
the type :
it's indicate : $ident; : string = 1
(1 because first primary key from the table customer)
but i think that php converts in integer a string starting by by character
meaning an integer

for the EnablerInput() function
i can't write tablo_client[ident] because
tablo_client is a form (and an object) and we can have more than one
object form in the document so : document.forms[0] , [1] ....
ident is an object in the form tablo_client and it's the only one with this
name
($ident =val["Id_client"] matching the primary key customer's table
document.tablo_client.ident should be ok ....

"Vicomte De Valmont" <NOSPAM@hotmail.com> a écrit dans le message de news:
bnhatg$71s$1@lacerta.tiscalinet.it...[color=blue]
> Jesus Christ, I meant:
> document.tablo_client[ident].disabled=false;
> no dot after client. Sorry but we're lending help a bit on the run, ciao
> Alberto
>
>[/color]


Vicomte De Valmont
Guest
 
Posts: n/a
#8: Jul 20 '05

re: function EnablerInput() not working


ciao guillame
I reply quoting your poiints:
[color=blue]
> we have $ident = val [Id_client]
> val["Id_client"] is the primary key, Id type integer i >retrieved[/color]
from

this is ok, insofar it has no rilevance for javascript: the only thing which
matters is that if you have a form field whose name is "ident", the returned
value is a string saying "ident".
Yet, you're not too clear about this: perhaps you mean that the value, a
string, could be any name. As long as the input field gets assigned as NAME=
the SAME name you will use for your function, then it is ok, but must be a
string and must be identical to the input name= ok?

[color=blue]
> it's indicate : $ident; : string = 1[/color]

ok it is a string. Yet, could I see a _couple_ of examples of the following:
print($ident);
thanks that would help a LOT!
[color=blue]
> (1 because first primary key from the table customer)
> but i think that php converts in integer a string starting by by[/color]
character[color=blue]
> meaning an integer[/color]

uhm, be sure that string doesn't start with a number. Maybe to be over
cautious you may want to pre-pend a leter before assigning it to the name=
and passing it to the function.
[color=blue]
> for the EnablerInput() function
> i can't write tablo_client[ident] because
> tablo_client is a form (and an object) and we can >have more than one
> object form in the document so : document.forms[0] , [1] ....[/color]

if you can have more than a form, why then you're calling in your javascript
function with hard coded within it only _one_name: tablo_client?
[color=blue]
> ident is an object in the form tablo_client and it's the only one with[/color]
this[color=blue]
> name
> ($ident =val["Id_client"] matching the primary key customer's table
> document.tablo_client.ident should be ok ....[/color]

No it would not. The issue is the ARGUMENT you pass to the function: it is
named ident, and then you quote it in the body as
document.tablo_client.ident
that doesn't work, guillaume.
To get persuaded try this:
<body>
<script>
document.aProp='hallo';
function foo(arg){
alert(document.arg);
}
foo('aProp');
</script>
</body>
Try it. And trust me a bit :) I'm not dispatching rubbish to you :)))
You have to understand this point: when you pass a parameter to a function
by php, you do NOT pass a javascript object. Unless, of course, you rebuild
it as such. Yet, again, it is not clear what value you get from $ident. I'd
like to see it printed if possible.
1) if you get a STRING, then you do have to use the associative power of the
array:
document.tablo_client[ident]
if tablo_client can be a name that could vary because you have more forms,
your javascript code didn't represent this situation, it is impossible to
guess then: on the one hand you say you have more forms, yet in your
javascript you hard code one name alone you see.
2) you can rebuild the reference to the object like this:
$myParameter="document.".$NomeForm.".".$ident
note the sequences of dot quote dot.
then you can do as follow: you put in the input name
name=<?$ident?>
please verify if you should aslo add escaped double quotes. I leave it to
you, but the name should be in between quotes in javascript.
Then
a href='javascript:EnablerInput(<? $myParameter; ?>);'
this passes an OBJECT because $myParameter assembled a text which is a
reference to an object;
and now in your js function:
function EnablerInput(ident){
ident.disabled=false;
}

ciao
Alberto Vallini
http://www.unitedscripters.com/



[color=blue]
>
> "Vicomte De Valmont" <NOSPAM@hotmail.com> a écrit dans le message de news:
> bnhatg$71s$1@lacerta.tiscalinet.it...[color=green]
> > Jesus Christ, I meant:
> > document.tablo_client[ident].disabled=false;
> > no dot after client. Sorry but we're lending help a bit on the run, ciao
> > Alberto
> >
> >[/color]
>
>[/color]


Vicomte De Valmont
Guest
 
Posts: n/a
#9: Jul 20 '05

re: function EnablerInput() not working


Ok, here is a full working example, try it.

<?php
$ident="aName";/*let's assume this is what you got from your sql query ok?*/
$formName="dunno";
//now:
$validJSreference="document.$formName.$ident";
//now:
print("<html><body>");
print("<script>function
EnablerInput(ident){ident.disabled=false;}</script>");
print("<form name=\"$formName\">");
print("<input type='text' name=\"$ident\" disabled value='try to delete
me'><br>");
print("<a href='#' onClick=\"EnablerInput($validJSreference); return
false;\">re-enable</a>");
print("</form></body></html>");
?>

ciao
Alberto Vallini
http://www.unitedscripters.com/




"guillaume" <pguillaume1@9online.fr> ha scritto nel messaggio
news:bnho1t$v2$1@aphrodite.grec.isp.9tel.net...[color=blue]
> thanks for your help again,
> we have $ident = val [Id_client]
> val["Id_client"] is the primary key, Id type integer i retrieved from
> the database
> but i used the debug Machine with a stop just after $ident to control
> the type :
> it's indicate : $ident; : string = 1
> (1 because first primary key from the table customer)
> but i think that php converts in integer a string starting by by[/color]
character[color=blue]
> meaning an integer
>
> for the EnablerInput() function
> i can't write tablo_client[ident] because
> tablo_client is a form (and an object) and we can have more than one
> object form in the document so : document.forms[0] , [1] ....
> ident is an object in the form tablo_client and it's the only one with[/color]
this[color=blue]
> name
> ($ident =val["Id_client"] matching the primary key customer's table
> document.tablo_client.ident should be ok ....
>
> "Vicomte De Valmont" <NOSPAM@hotmail.com> a écrit dans le message de news:
> bnhatg$71s$1@lacerta.tiscalinet.it...[color=green]
> > Jesus Christ, I meant:
> > document.tablo_client[ident].disabled=false;
> > no dot after client. Sorry but we're lending help a bit on the run, ciao
> > Alberto
> >
> >[/color]
>
>[/color]


Closed Thread


Similar JavaScript / Ajax / DHTML bytes