Loading ...
Sorry, an error occurred while loading the content.

beginner: can't set value in form

Expand Messages
  • Kevin Collins
    I have a list of transactions where the user can select a checkbox in order to close one or more transactions for the period. I assigned the value of each
    Message 1 of 6 , Dec 11, 2007
    • 0 Attachment
      I have a list of transactions where the user can select a checkbox in order
      to 'close' one or more transactions for the period. I assigned the value of
      each checkbox with the transaction data I need to look up the transaction in
      my database. E.g. value='12207007|1001|0001'. I'm building a comma
      delimited string with all the data I need in order to find and close those
      transactions selected by the user. I created a hidden form element named
      checkboxStr. The code returns the expected values as it reads the check
      boxes but FAILS when it tries to update checkboxStr. I'm sure I doing
      something really stupid but I cannot figure what it is. I would greatly
      appreciate any help.



      TIA



      Kevin



      <form action="/scripts/mgrqispi.dll" name="transactions" method="POST"
      onsubmit="checkform()" >

      <input type="hidden" name="checkboxStr" value="">

      ============================================================================
      ==============



      function checkform()

      {



      var form = document.transactions

      var myStr =""

      for (var i=0; i<form.elements.length; i++)



      {

      if (form.elements[i].checked)

      { myStr += "," +
      form.elements[i].value

      alert(myStr) // returns str value as expected ,
      12207007|1001|0001,12207007|1001|0002,etc




      }

      }



      form.checkboxStr.value = myStr.value

      alert(form.checkboxStr) // returns [object] and sends 'undefined' to my
      database app.

      }



      [Non-text portions of this message have been removed]
    • Tim Sabin
      Post the relavant sections of code so that we can analyze your problem. --Tim Sabin ... in order ... value of ... transaction in ... those ... named ... check
      Message 2 of 6 , Dec 12, 2007
      • 0 Attachment
        Post the relavant sections of code so that we can analyze your problem.

        --Tim Sabin


        > I have a list of transactions where the user can select a checkbox
        in order
        > to 'close' one or more transactions for the period. I assigned the
        value of
        > each checkbox with the transaction data I need to look up the
        transaction in
        > my database. E.g. value='12207007|1001|0001'. I'm building a comma
        > delimited string with all the data I need in order to find and close
        those
        > transactions selected by the user. I created a hidden form element
        named
        > checkboxStr. The code returns the expected values as it reads the
        check
        > boxes but FAILS when it tries to update checkboxStr. I'm sure I
        doing
        > something really stupid but I cannot figure what it is. I would
        greatly
        > appreciate any help.
        >
        >
        >
        > TIA
        >
        >
        >
        > Kevin
        >
        >
        >
        > <form action="/scripts/mgrqispi.dll" name="transactions"
        method="POST"
        > onsubmit="checkform()" >
        >
        > <input type="hidden" name="checkboxStr" value="">
        >
        >
        =======================================================================
        =====
        > ==============
        >
        >
        >
        > function checkform()
        >
        > {
        >
        >
        >
        > var form = document.transactions
        >
        > var myStr =""
        >
        > for (var i=0; i<form.elements.length; i++)
        >
        >
        >
        > {
        >
        > if (form.elements[i].checked)
        >
        > { myStr += "," +
        > form.elements[i].value
        >
        > alert(myStr) // returns str value as
        expected ,
        > 12207007|1001|0001,12207007|1001|0002,etc
        >
        >
        >
        >
        > }
        >
        > }
        >
        >
        >
        > form.checkboxStr.value = myStr.value
        >
        > alert(form.checkboxStr) // returns [object] and sends 'undefined'
        to my
        > database app.
        >
        > }
        >
        >
        >
        > [Non-text portions of this message have been removed]
        >
        >
        >
        > Visit http://aiaiai.com for more groups to join
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
      • Kevin Collins
        Tim, Thanks for the reply. The code is at the bottom of the email. Let me know what else I can do. Thanks again Kevin From: JavaScript_Official@yahoogroups.com
        Message 3 of 6 , Dec 12, 2007
        • 0 Attachment
          Tim,



          Thanks for the reply. The code is at the bottom of the email. Let me know
          what else I can do.



          Thanks again



          Kevin



          From: JavaScript_Official@yahoogroups.com
          [mailto:JavaScript_Official@yahoogroups.com] On Behalf Of Tim Sabin
          Sent: Wednesday, December 12, 2007 2:14 PM
          To: JavaScript_Official@yahoogroups.com
          Subject: Re: [JavaScript] beginner: can't set value in form



          Post the relavant sections of code so that we can analyze your problem.

          --Tim Sabin

          > I have a list of transactions where the user can select a checkbox
          in order
          > to 'close' one or more transactions for the period. I assigned the
          value of
          > each checkbox with the transaction data I need to look up the
          transaction in
          > my database. E.g. value='12207007|1001|0001'. I'm building a comma
          > delimited string with all the data I need in order to find and close
          those
          > transactions selected by the user. I created a hidden form element
          named
          > checkboxStr. The code returns the expected values as it reads the
          check
          > boxes but FAILS when it tries to update checkboxStr. I'm sure I
          doing
          > something really stupid but I cannot figure what it is. I would
          greatly
          > appreciate any help.
          >
          >
          >
          > TIA
          >
          >
          >
          > Kevin
          >
          >
          >
          > <form action="/scripts/mgrqispi.dll" name="transactions"
          method="POST"
          > onsubmit="checkform()" >
          >
          > <input type="hidden" name="checkboxStr" value="">
          >
          >
          ===========
          >
          >
          > function checkform()
          >
          > {
          >
          >
          >
          > var form = document.transactions
          >
          > var myStr =""
          >
          > for (var i=0; i<form.elements.length; i++)
          >
          >
          >
          > {
          >
          > if (form.elements[i].checked)
          >
          > { myStr += "," +
          > form.elements[i].value
          >
          > alert(myStr) // returns str value as
          expected ,
          > 12207007|1001|0001,12207007|1001|0002,etc
          >
          >
          >
          >
          > }
          >
          > }
          >
          >
          >
          > form.checkboxStr.value = myStr.value
          >
          > alert(form.checkboxStr) // returns [object] and sends 'undefined'
          to my
          > database app.
          >
          > }
          >
          >
          >







          [Non-text portions of this message have been removed]
        • David Smart
          In your alert box you use just the variable name: alert(myStr) but in your assignment statement you are using myStr.value Variables don t have a .value.
          Message 4 of 6 , Dec 13, 2007
          • 0 Attachment
            In your alert box you use just the variable name:

            alert(myStr)

            but in your assignment statement you are using

            myStr.value

            Variables don't have a .value.

            Regards, Dave S

            PS JavaScript statements - by definition - end in a semicolon. Please code
            that way, or at least put them in when you post code to a group.

            ----- Original Message -----
            From: "Kevin Collins" <kcollins@...>
            To: <javascript_official@yahoogroups.com>
            Sent: Wednesday, December 12, 2007 5:57 PM
            Subject: [JavaScript] beginner: can't set value in form


            >I have a list of transactions where the user can select a checkbox in order
            > to 'close' one or more transactions for the period. I assigned the value
            > of
            > each checkbox with the transaction data I need to look up the transaction
            > in
            > my database. E.g. value='12207007|1001|0001'. I'm building a comma
            > delimited string with all the data I need in order to find and close those
            > transactions selected by the user. I created a hidden form element named
            > checkboxStr. The code returns the expected values as it reads the check
            > boxes but FAILS when it tries to update checkboxStr. I'm sure I doing
            > something really stupid but I cannot figure what it is. I would greatly
            > appreciate any help.
            >
            >
            >
            > TIA
            >
            >
            >
            > Kevin
            >
            >
            >
            > <form action="/scripts/mgrqispi.dll" name="transactions" method="POST"
            > onsubmit="checkform()" >
            >
            > <input type="hidden" name="checkboxStr" value="">
            >
            > ============================================================================
            > ==============
            >
            >
            >
            > function checkform()
            >
            > {
            >
            >
            >
            > var form = document.transactions
            >
            > var myStr =""
            >
            > for (var i=0; i<form.elements.length; i++)
            >
            >
            >
            > {
            >
            > if (form.elements[i].checked)
            >
            > { myStr += "," +
            > form.elements[i].value
            >
            > alert(myStr) // returns str value as expected ,
            > 12207007|1001|0001,12207007|1001|0002,etc
            >
            >
            >
            >
            > }
            >
            > }
            >
            >
            >
            > form.checkboxStr.value = myStr.value
            >
            > alert(form.checkboxStr) // returns [object] and sends 'undefined' to my
            > database app.
            >
            > }
            >
            >
            >
            > [Non-text portions of this message have been removed]
            >
            >
            >
            > Visit http://aiaiai.com for more groups to join
            > Yahoo! Groups Links
            >
            >
            >
            >
          • Tim Sabin
            As was already pointed out, you also refer to myStr.value. .value only applies when you are dealing with DOM objects - text boxes and the like. Simple
            Message 5 of 6 , Dec 13, 2007
            • 0 Attachment
              As was already pointed out, you also refer to myStr.value. .value only
              applies when you are dealing with DOM objects - text boxes and the like.
              Simple variables do not have the value attribute.

              Semis are not required IF only one statement is present at a time;
              however, they are required in all other cases. Do yourself a favor and
              use semis as a matter of habit. :-)

              --Tim Sabin


              Kevin Collins wrote:
              > Tim,
              >
              >
              >
              > Thanks for the reply. The code is at the bottom of the email. Let me know
              > what else I can do.
              >
              >
              >
              > Thanks again
              >
              >
              >
              > Kevin
              >
              >
              >
              > From: JavaScript_Official@yahoogroups.com
              > [mailto:JavaScript_Official@yahoogroups.com] On Behalf Of Tim Sabin
              > Sent: Wednesday, December 12, 2007 2:14 PM
              > To: JavaScript_Official@yahoogroups.com
              > Subject: Re: [JavaScript] beginner: can't set value in form
              >
              >
              >
              > Post the relavant sections of code so that we can analyze your problem.
              >
              > --Tim Sabin
              >
              >
              >> I have a list of transactions where the user can select a checkbox
              >>
              > in order
              >
              >> to 'close' one or more transactions for the period. I assigned the
              >>
              > value of
              >
              >> each checkbox with the transaction data I need to look up the
              >>
              > transaction in
              >
              >> my database. E.g. value='12207007|1001|0001'. I'm building a comma
              >> delimited string with all the data I need in order to find and close
              >>
              > those
              >
              >> transactions selected by the user. I created a hidden form element
              >>
              > named
              >
              >> checkboxStr. The code returns the expected values as it reads the
              >>
              > check
              >
              >> boxes but FAILS when it tries to update checkboxStr. I'm sure I
              >>
              > doing
              >
              >> something really stupid but I cannot figure what it is. I would
              >>
              > greatly
              >
              >> appreciate any help.
              >>
              >>
              >>
              >> TIA
              >>
              >>
              >>
              >> Kevin
              >>
              >>
              >>
              >> <form action="/scripts/mgrqispi.dll" name="transactions"
              >>
              > method="POST"
              >
              >> onsubmit="checkform()" >
              >>
              >> <input type="hidden" name="checkboxStr" value="">
              >>
              >>
              >>
              > ===========
              >
              >> function checkform()
              >>
              >> {
              >>
              >>
              >>
              >> var form = document.transactions
              >>
              >> var myStr =""
              >>
              >> for (var i=0; i<form.elements.length; i++)
              >>
              >>
              >>
              >> {
              >>
              >> if (form.elements[i].checked)
              >>
              >> { myStr += "," +
              >> form.elements[i].value
              >>
              >> alert(myStr) // returns str value as
              >>
              > expected ,
              >
              >> 12207007|1001|0001,12207007|1001|0002,etc
              >>
              >>
              >>
              >>
              >> }
              >>
              >> }
              >>
              >>
              >>
              >> form.checkboxStr.value = myStr.value
              >>
              >> alert(form.checkboxStr) // returns [object] and sends 'undefined'
              >>
              > to my
              >
              >> database app.
              >>
              >> }
              >>
              >>
              >>
              >>
              >
              >
              >
              >
              >
              >
              >
              > [Non-text portions of this message have been removed]
              >
              >
              >
              > Visit http://aiaiai.com for more groups to join
              > Yahoo! Groups Links
              >
              >
              >
              >
              >
              >
            • Kevin Collins
              Tim and David, thanks so much for your help. I really do appreciate it. Kevin [Non-text portions of this message have been removed]
              Message 6 of 6 , Dec 13, 2007
              • 0 Attachment
                Tim and David, thanks so much for your help. I really do appreciate it.



                Kevin







                [Non-text portions of this message have been removed]
              Your message has been successfully submitted and would be delivered to recipients shortly.