function EnablerInput() not working

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • guillaume

    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($qu ery);

    // tant qu'il y a des fiches

    while ($val = mysql_fetch_arr ay($res))

    {

    $ident = $val["Id_client"]

    ?>

    <tr>

    <form name="tablo_cli ent">

    <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="javascrip t:supprimer(); id='<? echo $id; ?>' ">supprimer </a></td>

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


    </tr>


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


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

    function EnablerInput(id ent)

    {

    document.tablo_ client.ident.di sabled=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

    #2
    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_clie nt") 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





    "guillaume" <pguillaume1@9o nline.fr> ha scritto nel messaggio
    news:bnh313$hc4 $1@aphrodite.gr ec.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($qu ery);

    // tant qu'il y a des fiches

    while ($val = mysql_fetch_arr ay($res))

    {

    $ident = $val["Id_client"]

    ?>

    <tr>

    <form name="tablo_cli ent">

    <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="javascrip t:supprimer(); id='<? echo $id; ?>'
    ">supprimer </a></td>

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


    </tr>


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


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

    function EnablerInput(id ent)

    {

    document.tablo_ client.ident.di sabled=false; // error
    message ; document.tablo_ client.ident is not an object or is null

    }

    maybe should i create one form for each row ?



    Comment

    • guillaume

      #3
      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@la certa.tiscaline t.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_clie nt") 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@9o nline.fr> ha scritto nel messaggio
      > news:bnh313$hc4 $1@aphrodite.gr ec.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($qu ery);
      >
      > // tant qu'il y a des fiches
      >
      > while ($val = mysql_fetch_arr ay($res))
      >
      > {
      >
      > $ident = $val["Id_client"]
      >
      > ?>
      >
      > <tr>
      >
      > <form name="tablo_cli ent">
      >
      > <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="javascrip t:supprimer(); id='<? echo $id; ?>'
      > ">supprimer </a></td>
      >
      > <td><a href='javascrip t: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(id ent)
      >
      > {
      >
      > document.tablo_ client.ident.di sabled=false; // error
      > message ; document.tablo_ client.ident is not an object or is null
      >
      > }
      >
      > maybe should i create one form for each row ?
      >
      >
      >[/color]


      Comment

      • Vicomte De Valmont

        #4
        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='javascrip t:EnablerInput( <? $ident; ?>);
        this cannot be: IF $ident returns "ident" as I do hope (!!), you're sayng
        this:
        name="ident"
        AND
        a href='javascrip t: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='javascrip t:EnablerInput( "\"<? $ident; ?>\"");

        THEN:
        3)
        a href='javascrip t:EnablerInput( "\"<? $ident; ?>\"");
        has no meaning, even as
        a href='javascrip t:EnablerInput( <? $ident; ?>);
        IF the body of your function then says:
        function EnablerInput(id ent){document.t ablo_client.ide nt.disabled=fal se;}
        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.SomeObje ct.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_arr ay($res))

        {

        $ident = $val["Id_client"]

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


        ciao
        Alberto Vallini



        "guillaume" <pguillaume1@9o nline.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@la certa.tiscaline t.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_clie nt") 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@9o nline.fr> ha scritto nel messaggio
        > > news:bnh313$hc4 $1@aphrodite.gr ec.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($qu ery);
        > >
        > > // tant qu'il y a des fiches
        > >
        > > while ($val = mysql_fetch_arr ay($res))
        > >
        > > {
        > >
        > > $ident = $val["Id_client"]
        > >
        > > ?>
        > >
        > > <tr>
        > >
        > > <form name="tablo_cli ent">
        > >
        > > <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="javascrip t:supprimer(); id='<? echo $id; ?>'
        > > ">supprimer </a></td>
        > >
        > > <td><a href='javascrip t: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(id ent)
        > >
        > > {
        > >
        > > document.tablo_ client.ident.di sabled=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]


        Comment

        • Vicomte De Valmont

          #5
          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='javascrip t:EnablerInput( <? $ident; ?>);
          > this cannot be: IF $ident returns "ident" as I do hope (!!), you're sayng
          > this:
          > name="ident"
          > AND
          > a href='javascrip t: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='javascrip t:EnablerInput( "\"<? $ident; ?>\"");
          >[/color]


          Comment

          • Vicomte De Valmont

            #6
            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


            Comment

            • guillaume

              #7
              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@la certa.tiscaline t.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]


              Comment

              • Vicomte De Valmont

                #8
                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="d ocument.".$Nome Form.".".$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='javascrip t: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(id ent){
                ident.disabled= false;
                }

                ciao
                Alberto Vallini




                [color=blue]
                >
                > "Vicomte De Valmont" <NOSPAM@hotmail .com> a écrit dans le message de news:
                > bnhatg$71s$1@la certa.tiscaline t.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]


                Comment

                • Vicomte De Valmont

                  #9
                  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="dunn o";
                  //now:
                  $validJSreferen ce="document.$f ormName.$ident" ;
                  //now:
                  print("<html><b ody>");
                  print("<script> function
                  EnablerInput(id ent){ident.disa bled=false;}</script>");
                  print("<form name=\"$formNam e\">");
                  print("<input type='text' name=\"$ident\" disabled value='try to delete
                  me'><br>");
                  print("<a href='#' onClick=\"Enabl erInput($validJ Sreference); return
                  false;\">re-enable</a>");
                  print("</form></body></html>");
                  ?>

                  ciao
                  Alberto Vallini





                  "guillaume" <pguillaume1@9o nline.fr> ha scritto nel messaggio
                  news:bnho1t$v2$ 1@aphrodite.gre c.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@la certa.tiscaline t.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]


                  Comment

                  Working...