eval() not working in firefox

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

    eval() not working in firefox

    Hello Everybody,

    I have the following lines in my code

    1)
    totalElements=e val("document." +formname+".RCB illingCycle"+to talRCRows+".len gth")

    2) var newoption=new Option (BillingCycleNa me,BillingCycle Id);
    eval("document. "+formname+".RC BillingCycle"+t otalRCRows+".op tions[totalElements]=
    newoption");

    In both statements above, the eval code doesnt work in firefox. Is
    there a workaround?

    Regards,
    Angel

  • Richard Cornford

    #2
    Re: eval() not working in firefox

    Angel wrote:[color=blue]
    > Hello Everybody,
    >
    > I have the following lines in my code
    >
    > 1)
    > totalElements=e val("document." +formname+".RCB illingCycle"+to talRCRows+".len gth")
    >
    > 2) var newoption=new Option (BillingCycleNa me,BillingCycle Id);
    > eval("document. "+formname+".RC BillingCycle"+t otalRCRows+".op tions[totalElements]=
    > newoption");
    >
    > In both statements above, the eval code doesnt work in firefox. Is
    > there a workaround?[/color]

    No workaround is needed as there is no need to use - eval - at all and
    it is more likely the shortcut property accessors that is not working
    in Firefox.

    Replace:-

    eval("document. "+formname+".RC BillingCycle"+t otalRCRows+".le ngth")

    -with:-

    document.forms[formname].elements['RCBillingCycle '+totalRCRows].length;

    - and replace:-

    eval("document. "+formname+".RC BillingCycle"+t otalRCRows+
    ".options[totalElements]= newoption");

    -with:-

    document.forms[formname].elements['RCBillingCycle '+
    totalRCRows].options[totalElements]= newoption

    Richard.

    Comment

    • Angel

      #3
      Re: eval() not working in firefox

      Implemented the code. Got the following error

      document.forms[formname].elements['RCBillingCycle '+totalRCRows] has no
      properties



      Richard Cornford wrote:[color=blue]
      > Angel wrote:[color=green]
      > > Hello Everybody,
      > >
      > > I have the following lines in my code
      > >
      > > 1)
      > > totalElements=e val("document." +formname+".RCB illingCycle"+to talRCRows+".len gth")
      > >
      > > 2) var newoption=new Option (BillingCycleNa me,BillingCycle Id);
      > > eval("document. "+formname+".RC BillingCycle"+t otalRCRows+".op tions[totalElements]=
      > > newoption");
      > >
      > > In both statements above, the eval code doesnt work in firefox. Is
      > > there a workaround?[/color]
      >
      > No workaround is needed as there is no need to use - eval - at all and
      > it is more likely the shortcut property accessors that is not working
      > in Firefox.
      >
      > Replace:-
      >
      > eval("document. "+formname+".RC BillingCycle"+t otalRCRows+".le ngth")
      >
      > -with:-
      >
      > document.forms[formname].elements['RCBillingCycle '+totalRCRows].length;
      >
      > - and replace:-
      >
      > eval("document. "+formname+".RC BillingCycle"+t otalRCRows+
      > ".options[totalElements]= newoption");
      >
      > -with:-
      >
      > document.forms[formname].elements['RCBillingCycle '+
      > totalRCRows].options[totalElements]= newoption
      >
      > Richard.[/color]

      Comment

      • RobG

        #4
        Re: eval() not working in firefox

        Angel wrote:[color=blue]
        > Implemented the code. Got the following error[/color]

        Please don't top post here, reply below a trimmed quote.

        [color=blue]
        > document.forms[formname].elements['RCBillingCycle '+totalRCRows] has no
        > properties[/color]

        That will return a reference to a form with a name attribute value equal
        to the value of - formname - and an element with a name attribute equal
        to the value of - 'RCBillingCycle ' + totalRCRows -.

        e.g.:

        <form name="formA" action="">
        <input type="text" name="RCBilling Cycle0">
        </form>

        <script type="text/javascript">

        var formname = "formA";
        var totalRCRows = '0';

        // Wrapped for posting
        alert(typeof
        document.forms[formname].elements['RCBillingCycle '+totalRCRows]
        );

        </script>

        [...]

        --
        Rob

        Comment

        • Matt Kruse

          #5
          Re: eval() not working in firefox

          Angel wrote:[color=blue]
          > I have the following lines in my code
          > totalElements=e val("document." +formname+".RCB illingCycle"+to talRCRows+".len gth")
          > ...[/color]



          --
          Matt Kruse




          Comment

          Working...