Submit a form in or out a foreach - forms

I have a servlet webapplication with jsp related to some servlets, among them, I have this form:
<form action="MeetingDetails" method="post">
<input type="hidden" name="mtgid" value="${selectMeeting.id}"/>
<c:forEach items="${comments}" var="comment" varStatus="i">
<p><input type="hidden" name="cmtid" value="${comment.getKey()}"/>
<c:out value="${comment.getKey()}"/> - <c:out value="${comment.getValue()}"/>
<input id="minus" type="submit" name="action" value="DeleteComment"/></p>
</c:forEach>
<p>New Comment: <input type="text" name="cmt" value=""> <input id="plus" type="submit" name="action" value="AddComment"/></p>
</form>
And when I send the action:Delete to the servlet, it recieves a wrong "cmtid" value, and if I put the form within the foreach, the parameter "mtgid" value is null...
Is there anyway to do this?
Thank you.

Sorry for the inconvenient, I figured it out by:
<c:forEach items="${comments}" var="comment" varStatus="i">
<form action="MeetingDetails" method="post">
<input type="hidden" name="mtgid" value="${selectMeeting.id}"/>
<p><input type="hidden" name="cmtid" value="${comment.getKey()}"/>
<c:out value="${comment.getKey()}"/> - <c:out value="${comment.getValue()}"/>
<input id="minus" type="submit" name="action" value="DeleteComment"/></p>
</form>
</c:forEach>
<form action="MeetingDetails" method="post">
<input type="hidden" name="mtgid" value="${selectMeeting.id}"/>
<p>New Comment: <input type="text" name="cmt" value=""> <input id="plus" type="submit" name="action" value="AddComment"/></p>
</form>
I was a little obfuscated and didn't see it

Related

HTML Form Basics for PayPal Payments Standard custom fields

I'm trying to put a PayPal form on my website but I would also like to put custom fields on it.
I mean, I would like to receive the details that maybe are different from the PayPal details.
Maybe someone does a payment but wants to use a PayPal account with a different email, so I would like to know both the emails.
I would like to create a form with these fields:
First name
Last name
Personal email (not Paypal email)
and I want to be able to see these information when I receive the payment.
This is my form:
<div id="paynow" class="contact_form_invoice_payment">
<div class="invoice_payment_title">Pay your invoice here</div>
<form method="post" action="https://www.paypal.com/cgi-bin/webscr">
<input value="_xclick" name="cmd" type="hidden">
<input value="nessa#stressless.ie" name="business" type="hidden">
<input value="http://www.matrix-test.com/stressless/" name="return" type="hidden">
<input value="0" name="no_shipping" type="hidden">
<input value="1" name="no_note" type="hidden">
<input value="EUR" name="currency_code" type="hidden">
<input value="IE" name="lc" type="hidden">
<input value="PP-BuyNowBF" name="bn" type="hidden">
<input value="0" name="tax" type="hidden">
<input value="Online Payment" name="item_name" type="hidden">
<input value="OP" name="item_number" type="hidden">
<div class="first_name_invoice_payment">
First name (requiered) <br />
<input value="" name="first_name">
</div>
<div class="last_name_invoice_payment">
Last name (requiered)<br />
<input value="" name="last_name">
</div>
<div class="email_invoice_payment">
Email (requiered)<br />
<input value="" name="email">
</div>
<div class="first_name_invoice_payment">
Invoice Number (requiered)<br />
<input id="inv" value="" name="item_number">
</div>
<div class="last_name_invoice_payment">
Amount - Euro Only (requiered)<br />
<input id="amt" value="" name="amount">
</div>
<div class="job_title_invoice_payment">
<input alt="PayPal - The safer, easier way to pay online!" name="submit" border="0" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif" type="image" class="no-width image" style="width:auto !important; border:none; margin-top:20px;">
<img height="1" width="1" src="https://www.paypal.com/en_US/i/scr/pixel.gif" border="0" alt="">
</div>
</form>
</div>
I tried to put these fields:
name="first_name"
name="last_name"
name="email"
but I can't see them in the PayPal email and even in the PayPal backoffice.
Try using the variables below to gather the information you are looking for:
on0 = CustomerName
os0 = "Enter First and Last Name"
on1 = CustomerEmail
os1 = "Enter Email Address"
Developer: https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/
Your updated code would look similar to this:
<input value="CustomerName" name="on0" type="hidden">
<input value="CustomerEmail" name="on1" type="hidden">
<div class="first_name_invoice_payment">
First/Last name (requiered) <br />
<input value="" name="os0">
</div>
<div class="email_invoice_payment">
Email (requiered)<br />
<input value="" name="os1">
</div>

Jsoup multiple forms with controls with same name

All this html on same page:
<form name="name1" ....>
<input name="tName"type="text">
<input value="Search" type="submit">
</form>
<form name="name2"....>
<input name="tName" type="text">
<input value="Search" type="submit">
</form>
doc = Jsoup.connect("addr")
.data("tName", "foo")
.userAgent("Mozilla")
.post();
Now, how do I know which form I submited ? Where to specify to which of 2 forms inputed data belogs to, in jsoup code ?
<form name="name1" ....>
<input name="tName"type="text">
<input value="Search" type="submit">
<input name="formNumber" value="form1" type="hidden">
</form>
<form name="name2"....>
<input name="tName" type="text">
<input value="Search" type="submit">
<input name="formNumber" value="form2" type="hidden">
</form>
doc = Jsoup.connect("addr")
.data("tName", "foo")
.userAgent("Mozilla")
.post();
If you can't get the name of the form itself, you'll be able to get the values of the hidden inputs.

Bypass onclick form search value

JSFiddle: https://jsfiddle.net/apamvz1r/1/
I have the following code that I would like to eliminate the need for the visitor to click the radio button before searching... Is this possible? I would like to completely eliminate this field or hide it.
<input type="radio" name="RProducts" onclick="frmSearch.Products.value='BB'">
If you don't click on the radio input, it doesn't work properly, even if i pre-select it, it still needs to be directly clicked on. Is there a way around this?
<form action="http://search1.bestbenefits.com/provsearch.asp" method="post" name="frmSearch" id="frmSearch" target="_blank" onSubmit="return CheckParams()">
<input type="hidden" name="Products" value="">
<input type="hidden" name="Title" value="24-7_MedPlan-20140416">
<input type="radio" name="RProducts" onclick="frmSearch.Products.value='BB'">Search Providers
<br />Zip Code: <input type="text" size="9" name="Zip" maxlength="5"><br />
<input type="submit" value="Search for Providers">
</form>
This works for me:
<form action="http://search1.bestbenefits.com/provsearch.asp" method="post" name="frmSearch" id="frmSearch" target="_blank" onSubmit="return CheckParams()">
<input type="hidden" name="Products" value="">
<input type="hidden" name="Title" value="24-7_MedPlan-20140416">
<input checked="checked" type="radio" name="RProducts" onclick="frmSearch.Products.value='BB'">Search Providers
<br />Zip Code: <input type="text" size="9" name="Zip" maxlength="5"><br />
<input type="submit" value="Search for Providers">
</form>

Modx FormIt, got 2 forms, formit send both

This is my code, I can't understand why formit sends both the forms. It means I have 2 messages instead of one.
I use two templates and different &prefix:
[[!FormIt?
&hooks=`spam,email,emailUser`
&emailTo=`sitename#gmail.com`
&emailFromName=`[[+name]]`
&emailTpl=`ContactTpl`
&prefix="fi"
]]
<div>[[+fi.error.error_message]]</div>
<form action="[[~[[*id]]]]" method="post" id="recall">
<input type="hidden" name="nospam:blank" value="" />
<input type="text" name="name" class="right" id="recall_name" required="required" value="[[+fi.name]]">
<input type="number" name="number" class="right" id="recall_number"value="[[+fi.number]]" >
<textarea name="message:required:stripTags" value="[[+fi.message]]"></textarea>
<input type="submit">
</form>
[[!FormItRetriever]]
[[!FormIt?
&hooks=`spam,email,emailUser`
&emailTo=`sitename#gmail.com`
&prefix="cs"
&emailFromName=`[[+sup_name]]`
&emailTpl=`SupportTpl`
]]
<div>[[+fi.error.error_message]]</div>
<form action="[[~[[*id]]]]" method="post" id="support">
<input type="hidden" name="nospam:blank" value="" />
<label for="name" class="right" >Имя:</label>
<input type="text" name="name" class="right" id="support_name" required="required" value="[[+cs.sup_name]]">
<input type="number" name="number" value="[[+cs.sup_number]]">
<textarea name="message:required:stripTags"value="[[+cs.sup_message]]"></textarea>
<input type="submit">
</form>
take a look at the submitVar attribute: http://rtfm.modx.com/extras/revo/formit
your formit calls don't know which form they should be submitting. Set a name on each form submit control and set the submitVar for each in your formit calls.

Need to pass user input from 1 form to another on the same page

I am do not know .php at all but have a problem on one of my websites.
1. There are 2 forms for payment processing on a single page.
2. Each form has a separate submit button.
The problem.
I need to pass some of the user input from form one on to form two.
Note. this is on the same page.
Form 1
<input type="hidden" name="payfast_url" id="payfast_url" value="https://www."/>
<input type="hidden" name="merchant_id" id="merchant_id" value="xxxxx"/>
<input type="hidden" name="merchant_key" id="merchant_key" value="xxxxx"/>
<input type="hidden" name="return_url" id="return_url" value="payment_finished.html"/>
<input type="hidden" name="cancel_url" id="cancel_url" value="payment_cancelled.html"/>
<input type="hidden" name="notify_url" id="notify_url" value="/payment_notify.html"/>
<input type="hidden" name="item_name" id="item_name" value="Product name"/>
<input type="hidden" name="item_description" id="item_description"value="description"/>
<input type="hidden" name="email_confirmation" id="email_confirmation" value="1"/>
<input type="hidden" name="confirmation_address" id="confirmation_address" value=""/>
<input type="hidden" name="amount" id="amount" value="price" />
<input type="hidden" name="payment_id" id="payment_id" value="website_sales" />
<span class="formlable">Name</span><input name="name_first" id="name_first"type="text" value="" class="forminput"/>
<span class="formlable">Surname</span> <input name="name_last" id="name_last" type="text" value="" class="forminput"/>
<span class="formlable">E-Mail</span> <input type="text" name="email_address" id="email_address" value="" class="forminput"/>
<span class="formlable">Post Address</span> <input name="custom_str1" id="custom_str1" type="text" value="" class="forminput"/>
<span class="formlable">City</span><input name="custom_str2" id="custom_str2" type="text" value="" class="forminput"/>
<span class="formlable">Postal Code</span><input name="custom_str3" id="custom_str3" type="text" value="" class="forminput"/>
<input type="button" value="EFT Payment" onclick="quickPostPaymentToPayFast(document.getElementById('payfast_url').value);" id="button" method="post"/>
Form 2
<form name="CreditCards" action="https://www.mygate.co.za/.cfm" method="post"/>
<input type="hidden" name="Mode" id="Mode" value="0"/>
<input type="hidden" name="txtMerchantID" id="txtMerchant" value="xxxxxxx"/>
<input type="hidden" name="txtApplicationID" id="txtApplicationID" value="xxxxxxxx"/>
<input type="hidden" name="txtMerchantReference" id="txtMerchantReference" value="1234"/>
<input type="hidden" name="txtPrice" id="txtPrice" value="1234"/>
<input type="hidden" name="txtCurrencyCode" id="txtCurrencyCode" value="ZAR"/>
<input name="txtRedirectSuccessfulURL" value="success_failure.php" readonly="true" type="hidden"/>
<input name="txtRedirectFailedURL" value="success_failure.php" readonly="true" type="hidden"/ >
<input type="hidden" name="txtQty" id="txtQty" value="1"/>
<input type="hidden" name="txtItemDescr" id="txtItemDescr" value="descr"/>
<input type="hidden" name="txtItemAmount" id="txtItemAmount" value="449.00"/>
<input type="hidden" name="txtRecipient" value="<?php $_POST["name_first"]; ?>"/>
<input type="hidden" name="txtShippingAddress1" value="<?php $_POST["name_last"]; ?>"/>
<input type="hidden" name="txtShippingAddress2" value="<?php $_POST["email_address"]; ?>"/>
<input type="hidden" name="txtShippingAddress3" value="<?php $_POST["custom_str1"]; ?>"/>
<input type="hidden" name="txtShippingAddress4" value="<?php $_POST["custom_str2"]; ?>"/>
<input type="hidden" name="txtShippingAddress5" value="<?php $_POST["custom_str3"] ?>"/>
<input type="submit" id="button4" value="Credit card" />
</form>
name_first
name_last
email_address
custom_str1
custom_str2
Custom-str3
from the first form must be transfered into the second form as well
thanks
You should think of using some client-side JavaScript. I'd recommend using jQuery.
Not sure whether you have any experience in JS but that won't be very complex.
Basically, all you have to do is:
1) Read the value of the first input
email = $('#email_address').val()
2) Assign it to the other field (not sure what fields you want to assign)
$('#txtShippingAddress2').val(email)
Then just bind this code to your submit button or anywhere you need it.
You can find out more about jQuery at http://jquery.com/