Accessing values from 2 seperate forms

Results 1 to 2 of 2

Thread: Accessing values from 2 seperate forms

  1. #1
    Join Date
    Dec 1969

    Default Accessing values from 2 seperate forms

    I&#039ve got 2 forms on 1 page, when one is submitted, I also want to do something with the value of a textbox on the other form.<BR><BR>function frmAddToOrder_onsubmit() {<BR> var OpenUrl<BR> if (document.frmAddToOrder.txtQty.value &#062; 0)<BR> { <BR> OpenUrl = "OrderProduct.asp?ModelCode=" + document.frmModelCode.txtThisModel.value + "&amp;Qty=" + document.frmAddToOrder.txtQty.value<BR> (OpenUrl,&#039win&#039,&#039TOP=70,LEFT=75,HEIGHT= 200,WIDTH=640,toolbar=no,menubar=no,scrollbars=yes &#039)<BR> }<BR> return false<BR>} (pardon the tabs)<BR><BR>basically, what has to happen is I wanrt the browser to launch a new page with the values of the text boxes tacked on as a query string. I am using 2 forms, because I want the user to only have to hit enter after they put a value in a text box (when they hit enter, I want the button to click), and I don&#039t know how to do this without using submit forms, or responding to the keypress event of the text boxes, but I&#039m afraid that won&#039t work in Netscape.<BR>Any help would be appreciated.<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Accessing values from 2 seperate forms

    &nbsp;<BR>You mean you want the form(s) to submit when ENTER is hit on *either* of the text boxes? Even if the other text box is not yet filled in?<BR><BR>Strange, but if that&#039s what you want...<BR><BR>****************<BR><BR>&#060;HTML& #062;&#060;BODY&#062;<BR><BR>&#060;FORM Name="Form1" Action="OrderProduct.asp" Method="POST"<BR> onSubmit = "this.CopyField.value=document.Form2.FromField.val ue;return true;"&#062;<BR>&#060;INPUT Name="whatever" Value="something"&#062;<BR>&#060;INPUT TYPE=HIDDEN Name="CopyField"&#062;<BR>&#060;/FORM&#062;<BR><BR>&#060;FORM Name="Form2" <BR> onSubmit = "document.Form1.CopyField.value=this.FromField.val ue;document.Form1.submit();return false;"&#062;<BR>&#060;INPUT Name="FromField"&#062;<BR>&#060;/FORM&#062;<BR><BR>************<BR><BR>See it? If Form2 tries to submit, what actually happens is that the value of its field is copied to the hidden field in Form1 and then form1 is submitted.<BR><BR>If Form1 tries to submit, it first copies the value of the field from Form2 into its own hidden field before allowing the submit to proceed.<BR><BR>The copying code must be duplicated because the "onSubmit" event in Form1 is *not* activated by the coded submit from Form2.<BR><BR>There&#039s a quiz on Monday. <BR><BR>There are surely many other ways to do this.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts