Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combining form fields, then updating

Status
Not open for further replies.

originalxavier

Programmer
Mar 5, 2003
69
US
Hello,

I have a form that I am using to update records. The problem is this... I want users to be able to add comments to what is already there but not delete them. I have been able to join the two fields "originalcomments" and the new comments "IRM_.._COMMENTS". But with the way I have the code below, it will not submit the data. It will join the fields properly and give me the alert, but nothing will be updated and it will redirect you as it should

Without the JavaScript, the update code worked fine. I was able to have dynamic fields where users could modify the data, and update it. But with the code below... It will not do the actual updating.

If I change the onclick to onsubmit, the JavaScript will not work and it still will not update.

THE CODE:

<head>
<title>Update Information</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; />
<script language=&quot;JavaScript&quot;>
function combine() {
if (form1.IRM_BIENNIAL_COMMENTS.value.length > 0) {
alert(&quot;Something is there!&quot;)
var text = form1.OriginalComment.value + &quot; &quot; + form1.IRM_BIENNIAL_COMMENTS.value;
form1.CombinedComment.value = text;
}
return true;
}
</script>
</head>

...
<form ACTION=&quot;<%=MM_editAction%>&quot; method=&quot;POST&quot; name=&quot;form1&quot;>

(THE FORM IS HERE)

<input name=&quot;submit&quot; type=&quot;submit&quot; value=&quot;Update Record&quot; onclick=&quot;return combine()&quot; />





Let me know if more info is needed.

Thanks,

Xavier

----------------------------------------
&quot;Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far the Universe is winning.&quot;
Rick Cook
----------------------------------------
 
this &quot;form1.CombinedComment.value = text&quot;
does exist in the form?

> need more info?
:: don't click HERE ::
 
Sorry... Here is the whole form....

Code:
<P align=&quot;center&quot;><font color=&quot;00008A&quot; size=&quot;+3&quot;><strong>Update Information</strong></font></P>
<form ACTION=&quot;<%=MM_editAction%>&quot; method=&quot;POST&quot; name=&quot;form1&quot;>
  <table width=&quot;445&quot; height=&quot;380&quot; align=&quot;center&quot; cellpadding=&quot;1&quot;>
    <tr valign=&quot;baseline&quot;> 
      <td width=&quot;206&quot; height=&quot;19&quot; align=&quot;right&quot; nowrap> <div align=&quot;right&quot;><strong>PCN:</strong></div></td>
      <td width=&quot;227&quot; bordercolor=&quot;#000000&quot;><strong><font color=&quot;#0000FF&quot;><%=(Recordset1.Fields.Item(&quot;PCN&quot;).Value)%></font></strong> </td>
    </tr>
    <tr valign=&quot;baseline&quot;> 
      <td height=&quot;24&quot; align=&quot;right&quot; nowrap><strong>G-504:</strong></td>
      <td><input type=&quot;text&quot; name=&quot;G504&quot; value=&quot;<%=(Recordset1.Fields.Item(&quot;G-504&quot;).Value)%>&quot; size=&quot;32&quot; /> 
      </td>
    </tr>
    <tr valign=&quot;baseline&quot;> 
      <td height=&quot;26&quot; align=&quot;right&quot; nowrap><strong>Airbill::</strong></td>
      <td><input type=&quot;text&quot; name=&quot;AIRBILL&quot; value=&quot;<%=(Recordset1.Fields.Item(&quot;AIRBILL&quot;).Value)%>&quot; size=&quot;32&quot; /> 
      </td>
    </tr>
    <tr valign=&quot;baseline&quot;> 
      <td height=&quot;24&quot; align=&quot;right&quot; nowrap><strong>Serial Number:</strong></td>
      <td><input type=&quot;text&quot; name=&quot;SERIAL_NUMBER&quot; value=&quot;<%=(Recordset1.Fields.Item(&quot;SERIAL NUMBER&quot;).Value)%>&quot; size=&quot;32&quot; /> 
      </td>
    </tr>
    <tr valign=&quot;baseline&quot;> 
      <td height=&quot;&quot; align=&quot;right&quot; nowrap><strong>Item Description:</strong></td>
      <td bordercolor=&quot;#000000&quot;><strong><font color=&quot;#0000FF&quot;><%=(Recordset1.Fields.Item(&quot;ITEM DESCRIPTION&quot;).Value)%></font></strong> </td>
    </tr>
    <tr valign=&quot;baseline&quot;> 
      <td height=&quot;&quot; align=&quot;right&quot; nowrap><strong>2002 IRM Biennial Comments:</strong></td>
      <td bordercolor=&quot;#333333&quot;><strong><font color=&quot;#0000FF&quot;><%=(Recordset1.Fields.Item(&quot;2002Comments&quot;).Value)%></font></strong></td>
    </tr>
    <tr valign=&quot;baseline&quot;> 
      <td height=&quot;&quot; align=&quot;right&quot; valign=&quot;top&quot; nowrap><strong>Existing 2003 Biennial 
        Comments:</strong></td>
      <td><font color=&quot;0000FF&quot;><strong><%=(Recordset1.Fields.Item(&quot;2003_IRM_BIENNIAL_COMMENTS&quot;).Value)%></strong></font></td>
    </tr>
    <tr valign=&quot;baseline&quot;> 
      <td height=&quot;24&quot; align=&quot;right&quot; valign=&quot;top&quot; nowrap><p><strong>2003 IRM Biennial 
          Comments:</strong></p></td>
      <td><strong><font color=&quot;0000FF&quot;> 
        <textarea name=&quot;IRM_BIENNIAL_COMMENTS&quot; cols=&quot;32&quot; rows=&quot;6&quot;></textarea>
        </font> </strong> </td>
    </tr>
    <tr valign=&quot;baseline&quot;> 
      <td height=&quot;20&quot; align=&quot;right&quot; nowrap><strong> Completion Status:</strong></td>
      <td><strong> 
        <select name=&quot;CurrentStatus&quot;>
          <%
While (NOT RecordStatus.EOF)
%>
          <option value=&quot;<%=(RecordStatus.Fields.Item(&quot;Value&quot;).Value)%>&quot; <%If (Not isNull((Recordset1.Fields.Item(&quot;RESULTS&quot;).Value))) Then If (CStr(RecordStatus.Fields.Item(&quot;Value&quot;).Value) = CStr((Recordset1.Fields.Item(&quot;RESULTS&quot;).Value))) Then Response.Write(&quot;SELECTED&quot;) : Response.Write(&quot;&quot;)%> ><%=(RecordStatus.Fields.Item(&quot;Status&quot;).Value)%></option>
          <%
  RecordStatus.MoveNext()
Wend
If (RecordStatus.CursorType > 0) Then
  RecordStatus.MoveFirst
Else
  RecordStatus.Requery
End If
%>
        </select>
        </strong></td>
    </tr>
    <tr valign=&quot;baseline&quot;> 
      <td height=&quot;26&quot; align=&quot;right&quot; nowrap><strong>Print Status:</strong></td>
      <td><strong> 
        <select name=&quot;select&quot;>
          <%
While (NOT printoptions.EOF)
%>
          <option value=&quot;<%=(printoptions.Fields.Item(&quot;Value&quot;).Value)%>&quot; <%If (Not isNull((printoptions.Fields.Item(&quot;Value&quot;).Value))) Then If (CStr(printoptions.Fields.Item(&quot;Value&quot;).Value) = CStr((printoptions.Fields.Item(&quot;Value&quot;).Value))) Then Response.Write(&quot;SELECTED&quot;) : Response.Write(&quot;&quot;)%> ><%=(printoptions.Fields.Item(&quot;Status&quot;).Value)%></option>
          <%
  printoptions.MoveNext()
Wend
If (printoptions.CursorType > 0) Then
  printoptions.MoveFirst
Else
  printoptions.Requery
End If
%>
        </select>
        </strong></td>
    </tr>
    <tr valign=&quot;baseline&quot;> 
      <td height=&quot;26&quot; align=&quot;right&quot; nowrap><strong>Point Of Contact<font color=&quot;#0000FF&quot;>:</font></strong>  </div></td>
      <td><strong><font color=&quot;#0000FF&quot;><%=(Recordset1.Fields.Item(&quot;POINT OF CONTACT&quot;).Value)%></font></strong></td>
    </tr>
    <tr valign=&quot;baseline&quot;> 
      <td height=&quot;26&quot; align=&quot;right&quot; colspan=&quot;2&quot;nowrap><div align=&quot;center&quot;> 
          <input name=&quot;submit&quot; type=&quot;submit&quot; value=&quot;Update Record&quot; onsubmit=&quot;return combine()&quot; />
        </div></td>
    </tr>
  </table>
  <input type=&quot;hidden&quot; name=&quot;MM_update&quot; value=&quot;form1&quot;>
  <input type=&quot;hidden&quot; name=&quot;MM_recordId&quot; value=&quot;<%= Recordset1.Fields.Item(&quot;PCN&quot;).Value %>&quot;>
  <input name=&quot;Updater&quot; type=&quot;hidden&quot; value=&quot;<%=(username.Fields.Item(&quot;Username&quot;).Value)%>&quot; />
  <input type=&quot;hidden&quot; name=&quot;TimeStamp&quot; value=&quot;<%=Date %>&quot;/>
  <input type=&quot;hidden&quot; name=&quot;OriginalComment&quot; value=&quot;<%=(Recordset1.Fields.Item(&quot;2003_IRM_BIENNIAL_COMMENTS&quot;).Value)%>&quot;/>
  <input name=&quot;CombinedComment&quot; type=&quot;text&quot; value=&quot;&quot;/>
</form>


Xavier

----------------------------------------
&quot;Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far the Universe is winning.&quot;
Rick Cook
----------------------------------------
 
As you can see, this is all pretty much dynamic data, some editable, some not... But when it only has one &quot;comments&quot; field where the user can delete the entire comments, it functions fine. When I added the JavaScript is when it stopped updating, and simply redirects like it was a success...

Xavier

----------------------------------------
&quot;Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far the Universe is winning.&quot;
Rick Cook
----------------------------------------
 
dynamic part does not play much of a part here....the field get populated and as such mean very little to JS.....follow the link above ;-)

think about using onClick vs. OnSubmit IF u have no validation...this way they are forced to click vs. accidentally hitting &quot;enter&quot; while the form is not compleated....
I would ****suggest**** also adding form validation before ANY submition!
All the best!

> need more info?
:: don't click HERE ::
 
OK, there is no validation on the page because I don't need them to validate anything. I guess I was unclear as to the problem.

The javascript above works when I have it referenced using &quot;onclick&quot;. BUT it does not update the data. It bypasses all of the update code as if it were not there. I thought that maybe this had something to do with the &quot;onclick&quot; instead of &quot;onsubmit&quot; and when I changed it, it didn't even call the javascript.

Bottom line is that I want it to update data by going to &quot;<%=MM_editAction%>&quot; AFTER the javascript has combined the two fields.

:)

Xavier

----------------------------------------
&quot;Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far the Universe is winning.&quot;
Rick Cook
----------------------------------------
 
u have 2 forms with the same name (form1).....JS can not tell which one ur trying to use....change the names.....
why do u need another hidden form tag
<input type=&quot;hidden&quot; name=&quot;MM_update&quot; value=&quot;form1&quot;>

double check the <%=MM_editAction%> that is correct page

All the best!

> need more info?
:: don't click HERE ::
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top