473,403 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

function EnablerInput() not working

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
8 1571
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Data Goob | last post by:
This one has me stumped. How did SuSE disable the mail() function in their RPM'd version of PHP? ( This is their install-version of PHP with RPMs not what you download from PHP.net ) I have...
5
by: amit kumar | last post by:
I am calling a function which returns pointer to a map. The declaration of the map is map<int,vectxyz*>. vectxyz is a vector containing pointer to a class xyz. For map<int,vectxyz*>* p1 In the...
39
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. ...
1
by: Julie May | last post by:
I have 90% of my function working and I know to get the next 10% it is justa matter of getting the quotations and the escaping quotations correct. Here is the portion that does work: <working...
0
by: serkan | last post by:
Guys, I am trying to get this password reset functionality wor for me but I am not successful at all. Please somebody help me. I get "Your password could not be reset - please try again later" so I...
1
by: den2005 | last post by:
Hi everybody, I am confused and still looking why this codes is not working. Can anyone notice or know why this code is not working? Thanks in advance. Code working: <form id="form1"...
10
by: SQACPP | last post by:
Hi, I try to figure out how to use Callback procedure in a C++ form project The following code *work* perfectly on a console project #include "Windows.h" BOOL CALLBACK...
3
by: BibhuAshish | last post by:
Hello guys i have one function which converts the ip/netmask into networkid/netmask and also it shows the message to user that his ip is changed to network id. but that function is working in...
7
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I am using this code to get groups for a user and getting a error (5) on the GetAuthorizationGroups() function . There are two domains. This function works on the local domain but does not work...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.