Wednesday, 15 April 2015

Validating a form created via php with javascript -


I have PHP form

Form elements are created based on the selection of users which are The dropdown menu is in.

The one I am trying to accomplish is a loop through that form and validates the values ​​of two elements with the "action" and "AMT" of the ID.

Now, I should mention the form which I am trying to validate, X elements of X elements can be because it should be based on the needs of the users. When I call my valid work, it checks the ID and alerts the value, however, this "AMT" alerts the value of the first input element with ID three / sometimes multiple times

This is bad because I need to make some calculations and error will be generated in calculating duplicate entries.

This is my script

  & lt; Script type = "text / javascript" & gt; Validate the function () {var i; Var passtest = 0; Var test = ""; Var form = document.getElementById ("myForm"); Warning ("Enter Function"); (I = 0; i  

Here is a PHP code that displays the form

  & lt; Form name = 'transaction' id = "myForm" onsubmit = "return validate ()" action = '' method = 'post' & gt; & Lt ;? Php if (isset ($ _ POST ['add'])) {if (isset ($ _ POST ['acctN'])) {resonant "table" id = 'myRow' style = '' & gt; "; Echo" & lt; Thead & gt; "; echo" & lt; Tr & gt; "; echo" & lt; Th & gt; Account name & lt; / Th> "echo" & lt; Th & gt; Action & lt; / Th> "echo" & lt; Th & gt; Quantity & lt; / Th> "echo" & lt; / Tr & gt; "; echo" & lt; / Thead & gt; "; foreign currency ($ _POST ['acctN'] as $ name) {$ query =" SELECT * FROM ChartOfAccounts WHERE account name = '$ name' "; $ result = mysqli_query ($ cxn , $ Query) or die (mysqli_error ($ cxn)); $ line = mysqli_fetch_assoc ($ result); echo "& lt; Tbody & gt; "; echo" & lt; Tr & gt; "echo" & lt; Td class = 'col-md-6' & gt; & Lt; Select name = 'account []' class = 'form-control' style = '' & gt; & Lt; Option & gt; ". $ Line ['account name']" & lt; / Options & gt; & Lt; / Select & gt; & Lt; / TD & gt; "; Ancho" & lt; Td class = 'col-md-2' & gt; & Lt; Select name = 'deborradd []' id = 'action' class = 'form-control' style = '' & gt; & Lt; Option value = 'debit' & gt; Debit & lt; / Option & gt; & Lt; Option value = 'credit' & gt; Credit & lt; / Option & gt; & Lt; / Select & gt; & Lt; / Td> "; Echo" & lt; Td class = 'col-md-2' & gt; & Lt; Input type = 'text' name = 'amount []' class = 'form-control' id = 'amt' style = '' / / gt; & Lt; Span id = 'amtTD' style = 'color: red;' & Gt; & Lt; / Span & gt; & Lt; / Td> "; Echo" & lt; Td class = 'col-sm-2' & gt; $ & Lt; / Td> "; echo" & lt; Td class = 'col-sm-2' & gt; & Lt; Button type = 'button' onclick = 'removecell ()' class = 'btn btn-danger =' = = remove 'name =' "$. Line ['accountName']" '> Remove & lt; / Button & gt; & Lt; / TD & gt; "echo" & lt; / Tr & gt; "echo"; & lt; / Tbody & gt; "; echo" & lt; / Table> ";} echo" & lt; Label style = 'margin-left: 7px;' & Gt; Documentation & lt; / Label & gt; "; echo" & lt; Textarea name = 'src-doc' class = 'form-control' rows = '4' cols = '50 'placeholder =' description 'style =' max-width: 575px; Margin-left: 8 pixels; '& Gt; & Lt; / Text field & gt; "; Echo" & lt; Div style = 'padding: 10px;' & Gt; "; echo" & lt; Label & gt; Source & lt; / Label & gt; "; echo" & lt; Input type = 'file' name = 'fileToUpload' id = 'fileToUpload' & gt; "echo" & lt; / Div> "; echo" & lt; Input type = 'submit' class = 'btn btn-primary' value = 'submit' name = 'subrins' style =' margin-top: 7px; Margin-left: 8px; ' />  

Thank you all and provide input.


No comments:

Post a Comment