By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,399 Members | 1,319 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,399 IT Pros & Developers. It's quick & easy.

function EnablerInput() not working

P: n/a
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 ?
Jul 20 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
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" <pg*********@9online.fr> ha scritto nel messaggio
news:bn**********@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 ?

Jul 20 '05 #2

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

"Vicomte De Valmont" <NO****@hotmail.com> a écrit dans le message de news:
bn**********@lacerta.tiscalinet.it...
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" <pg*********@9online.fr> ha scritto nel messaggio
news:bn**********@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 ?

Jul 20 '05 #3

P: n/a
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" <pg*********@9online.fr> ha scritto nel messaggio
news:bn**********@apollon.grec.isp.9tel.net...
thanks for your help , i have changed id---> name but it doesn't work
:-( bye

"Vicomte De Valmont" <NO****@hotmail.com> a écrit dans le message de news:
bn**********@lacerta.tiscalinet.it...
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" <pg*********@9online.fr> ha scritto nel messaggio
news:bn**********@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 ?


Jul 20 '05 #4

P: n/a
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

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; ?>\"");

Jul 20 '05 #5

P: n/a
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
Jul 20 '05 #6

P: n/a
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" <NO****@hotmail.com> a écrit dans le message de news:
bn**********@lacerta.tiscalinet.it...
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

Jul 20 '05 #7

P: n/a
ciao guillame
I reply quoting your poiints:
we have $ident = val [Id_client]
val["Id_client"] is the primary key, Id type integer i >retrieved 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?

it's indicate : $ident; : string = 1
ok it is a string. Yet, could I see a _couple_ of examples of the following:
print($ident);
thanks that would help a LOT!
(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
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.
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] ....
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?
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 ....
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/


"Vicomte De Valmont" <NO****@hotmail.com> a écrit dans le message de news:
bn**********@lacerta.tiscalinet.it...
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


Jul 20 '05 #8

P: n/a
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" <pg*********@9online.fr> ha scritto nel messaggio
news:bn*********@aphrodite.grec.isp.9tel.net...
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" <NO****@hotmail.com> a écrit dans le message de news:
bn**********@lacerta.tiscalinet.it...
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


Jul 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.