I use .after method in Jquery to insert the html element.
This is my Jquery Code
$('#add_terms').click(function () {
var i = $('#terms>textarea').length;
$terms = $('#terms' + i);
i++;
console.log($terms);
$terms.after('<br><br>' + i + '. <textarea id="terms' + i + '" name="terms[]" ' + 'cols="60" rows="2" style="vertical-align:middle;"></textarea>');
})
My html:
<table width="98%" cellspacing="1" cellpadding="3" style="border-collapse:separate; border-spacing:0px 10px;">
<form method="post" enctype="multipart/form-data" name="form1" id="form1" action='' target="_self">
<tr>
<td align="center"> terms</td>
<td id="terms">
1.
<textarea id="terms1" name="terms[]" cols="60" rows="2"
style="vertical-align:middle;"><?php echo $terms1?></textarea>
<br><br>
2.
<textarea id="terms2" name="terms[]" cols="60" rows="2"
style="vertical-align:middle;"><?php echo $terms2?></textarea>
<br>
<input id="add_terms" name="add_terms" type="button" class="bt-add" value="add" style="margin-top:10px">
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input id="add" name="add" type="submit">
<input id="clear" name="clear" type="reset" class="bt-return">
</td>
</tr>
</form>
</table>
I post the form,then I can get the value of terms1 and terms2 with using
print_r($_POST['terms']);
However, I can't get the value of terms3, terms4.
Hope this help you.
<form method="post" enctype="multipart/form-data" name="form1" id="form1" action='' target="_self">
<td align="center"> terms</td>
<td id="terms">
1.
<textarea id="terms1" name="terms[]" cols="60" rows="2"
style="vertical-align:middle;"><?php echo $terms1?></textarea>
<br><br>
2.
<textarea id="terms2" name="terms[]" cols="60" rows="2"
style="vertical-align:middle;"><?php echo $terms2?></textarea>
<br>
<input id="add_terms" name="add_terms" type="submit" class="bt-add" value="add" style="margin-top:10px">
</td>
</form>
Related
I would call a javascript-Function on a Remote-Server via Curl + PHP. The Submit-Button is a div-Element and call a function in by 'onclick'.
Steps of Scraper:
1. Login
2. Save session
3. Call a secure-link with session
Question: How to submit a form for Javascript "onclick" via curl?
I would implement a PHP-Scraper for following form:
<script language="JavaScript" type="text/javascript">
function logon() {
if(document.forms['form1'].elements["USERNAME"].value==""){
alert('foo');
document.forms['form1'].elements["USERNAME"].focus();
return paxReturn(false);
}
if(document.forms['form1'].elements["PASSWORD"].value==""){
alert('foo');
document.forms['form1'].elements["PASSWORD"].focus();
return paxReturn(false);
}
if (mywindow!=null) {
showObjectWithSrvlt('paxInfo','LoginServlet');
}
if((mywindow==null)||(mywindow.closed)) {
var prm ='toolbar=no,titlebar=no,directories=no,menubar=no,resizable=yes,scrollbars=yes,width=900,height=600,top=0,left=0';
mywindow = window.open("",'bar',prm);
}
document.forms['form1'].target = 'bar';
try{
mywindow.resizeTo(screen.width,screen.height);
}catch(e) {}
document.forms['form1'].submit();
try{
mywindow.focus();
}catch(e) {}
document.forms['form1'].elements["USERNAME"].value="";
document.forms['form1'].elements["PASSWORD"].value="";
/* grecaptcha.reset(); */
}
</script>
<form name="form1" method="post" target="foo" action="foo.jsp">
<input class="FormText" type="hidden" name="clickedButton" id="clickedButton" value="">
<input class="FormText" type="hidden" name="paxInfo" id="paxInfo" value="">
<div class="col-lg-10 col-md-12">
<div class="card mask">
<br>
<br>
<table class="login-table-list">
<tbody><tr>
<td><div align="right">Username: </div></td>
<td><input type="text" name="USERNAME" value="" maxlength=" 20" size=" 18" class="InputText " id="USERNAME" autocomplete="OFF"></td>
</tr>
<tr><td colspan="2"> </td></tr>
<tr>
<td><div align="right">Password: </div></td>
<td><b><input class="InputText" type="password" name="PASSWORD" size="18" value="" onkeypress="javascript:return login(event);" autocomplete="off"></b></td>
</tr>
<tr><td colspan="2"> </td></tr>
<tr>
<td></td>
<td>
<div style="width:27%; float:left;" class="stdbtnnrmWithFrameNoImage login-btn" onclick="javascript: if (disableButtonContent(this,false)) { logon() } ">
Login
</div>
</td>
</tr>
</tbody></table>
<br>
<br>
</div>
</div>
</form>
Thanks in advance for your help!
i'm setting up donate option on a website using przelewy24.pl. They have this startup template to send values by $_GET method to their website.
Everything works fine exept the amount field. Przelewy24 needs a gr amount (like cents) and i would like for the donor to type in integer in full zł (like $).
If the upper is not clear - when i type 100 in the field, it sends it to przelewy24 as 100 gr, whitch will be 1 zł.
I need to know how could i format the amount sent to them as in simple calculation - when 100 is typed, get sends 10000. (x*100)
The form used is shown below. The quick-start guide is avaliable here, but only in polish
<form method="get" action="https://sklep.przelewy24.pl/zakup.php">
<input type="hidden" name="z24_id_sprzedawcy" value="TWOJ_ID">
<input type="hidden" name="z24_crc" value="KLUCZ_ZAKUPU">
<input type="hidden" name="z24_return_url" value="TWOJASTRONA.PL">
<input type="hidden" name="z24_language" value="pl">
<table>
<tr>
<td align="right">Nazwa produktu:</td>
<td>
<input type="text" name="z24_nazwa" value="Opłata za rezerwację NR: 04/234/A3953">
</td>
</tr>
<tr>
<td align="right">Dodatkowy opis:</td>
<td>
<textarea name="z24_opis" style="width:250px">Dodatkowe informacje...
</textarea>
</td>
</tr>
<tr>
<td align="right">Do zapłaty:</td>
<td><input type="text" name="z24_kwota"></td><!--KWOTA W GROSZACH-->
</tr>
</table>
<input type="submit" value="zapłać z przelewy24.pl">
</form>
You can do it with a simple Javascript code.
You need to capture the value from input, transform it, and put the value on input hidden:
function formatMoney(e) {
document.getElementById('z24_kwota').value = (!isNaN(e.target.value) ? e.target.value : 0) * 100
// just to debug.. you can remove this line:
document.getElementById('final_value').innerHTML = document.getElementById('z24_kwota').value
}
<form method="get" action="https://sklep.przelewy24.pl/zakup.php">
<input type="hidden" name="z24_id_sprzedawcy" value="TWOJ_ID">
<input type="hidden" name="z24_crc" value="KLUCZ_ZAKUPU">
<input type="hidden" name="z24_return_url" value="TWOJASTRONA.PL">
<input type="hidden" name="z24_language" value="pl">
<table>
<tr>
<td align="right">Nazwa produktu:</td>
<td>
<input type="text" name="z24_nazwa" value="Opłata za rezerwację NR: 04/234/A3953">
</td>
</tr>
<tr>
<td align="right">Dodatkowy opis:</td>
<td>
<textarea name="z24_opis" style="width:250px">Dodatkowe informacje...
</textarea>
</td>
</tr>
<tr>
<td align="right">Do zapłaty:</td>
<td>
<input type="hidden" name="z24_kwota" id="z24_kwota">
<input type="text" onkeyup="formatMoney(event)"></td><!--KWOTA W GROSZACH-->
</tr>
</table>
<input type="submit" value="zapłać z przelewy24.pl">
</form>
<!-- you can remove this line: -->
Final Value: <span id="final_value"></span>
Try changing the value before submitting the form like below,
<form method="get" id="myform" action="https://sklep.przelewy24.pl/zakup.php">
<input type="hidden" name="z24_id_sprzedawcy" value="TWOJ_ID">
<input type="hidden" name="z24_crc" value="KLUCZ_ZAKUPU">
<input type="hidden" name="z24_return_url" value="TWOJASTRONA.PL">
<input type="hidden" name="z24_language" value="pl">
<table>
<tr>
<td align="right">Nazwa produktu:</td>
<td>
<input type="text" name="z24_nazwa" value="Opłata za rezerwację NR: 04/234/A3953">
</td>
</tr>
<tr>
<td align="right">Dodatkowy opis:</td>
<td>
<textarea name="z24_opis" style="width:250px">Dodatkowe informacje...
</textarea>
</td>
</tr>
<tr>
<td align="right">Do zapłaty:</td>
<td><input type="text" name="z24_kwota"></td><!--KWOTA W GROSZACH-->
</tr>
</table>
<input type="submit" value="zapłać z przelewy24.pl">
</form>
<script
src="http://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script type="text/javascript">
var firstSubmit = false;
$('#myform').on('submit',function(e){
if(!firstSubmit){
e.preventDefault();
firstSubmit = true;
var amount = parseInt($('input[name=z24_kwota]').val());
$('input[name=z24_kwota]').val(amount*100);
$('#myform').trigger('submit');
}
})
</script>
Note: I have given an id to the form as myform
<div id="option-action">
<form action="{{ path('lab_univer_cpanel') }}" method="post" enctype="multipart/form-data" >
<table>
<tr>
<td><label>Titre</label></td>
<td><input type="text" id="titre" name="titreNews"></td>
<td></td>
</tr>
<tr>
<td><label>Image</label></td>
<td><input type="file" id="image" name="image" /></td>
<td></td>
</tr>
<tr>
<td><label>Contenue</label></td>
<td><textarea name="content" ></textarea></td>
<td></td>
</tr>
<div class="submit">
<input type="submit" name="addNews" value="+" class="addbtn">
</div>
</table>
</form>
</div>
I don't find the file image in the controller
This is the code to get request :
if ($req->request->get('addNews')) {
$titre = $req->request->get('titreNews');
$content = $req->request->get('content');
$membre = $em->getRepository('LabUniverBundle:Member')
->findOneBy(array('nom'=>'user'));
$image = $req->files->get('image');
print_r($image);
The result is a blank page !
I test with an other form like that :
<form action="{{ path('lab_univer_cpanel')}}" method="post" enctype="multipart/form-data" >
<input type="file" name="image" />
<input type="submit" value="send" name="checkUpload" />
</form>
It works !!!
I built my own search engine at my website.
I want the output of my search at URL when I click Submit (as Search Button) is :
http://inindonesia.org/marketplace/tags/oleh-oleh-khas-medan
But, When I click Submit (search button), the output is :
http://inindonesia.org/marketplace/tags/?search=oleh+oleh+khas+medan&hidden=oleh-oleh-khas-medan&Submit=Cari+Produk
My code is :
<form autocomplete="off" action="/marketplace/tags/(i want this get parameter from the value input id "hidden", example : oleh-oleh-khas-medan)" method="GET">
<table border="0" border="0" cellpadding="2px" cellspacing="2px" width="100%" bgcolor="">
<tr>
<td style="font-size:12px; text-align:left;" width="80%">
<input id="search" name="search" type="text"/><input id="hidden" name="hidden" type="hidden"/>
</td>
<td style="font-size:12px; text-align:right;" width="20%">
<input id="searchsubmit" name="Submit" value="Cari Produk" type="submit">
FYI: I am using Wordpress at my site.
Any ideas to change the url parameter like I want?
Thanks
Try something like this..... or You want something Different? Explain?
HTML
<form autocomplete="off" action="" onsubmit="return submitform()" method="POST">
<table border="0" border="0" cellpadding="2px" cellspacing="2px" width="100%" bgcolor="">
<tr>
<td style="font-size:12px; text-align:left;" width="80%">
<input id="search" name="search" type="text"/><input id="hidden" name="hidden" type="hidden"/>
</td>
<td style="font-size:12px; text-align:right;" width="20%">
<input id="searchsubmit" name="Submit" value="Cari Produk" type="submit">
</td>
</tr>
</table>
</form>
JAVASCRIPT
<script type="text/javascript">
function submitform()
{
var hiddenFieldValue = document.getElementById('search').value;
hiddenFieldValue = hiddenFieldValue.replace(/\s+/g, '-').toLowerCase();
//alert(location.host+'/marketplace/tags/'+hiddenFieldValue);
window.location = 'http://'+location.host+'/marketplace/tags/'+hiddenFieldValue;
}
</script>
This is my html form requesting feedback.
What would the corresponding PHP form be to place on my webserver to send the email? I am new at website design and have only learnt CSS+ HTML.
<table width="518" border="0">
<tr>
<td width="165"><form name="form1" method="post" action="">
<label for="nameco">Name/Company</label>
:
</form></td>
<td width="343"><input name="nameco" type="text" id="nameco" size="70"></td>
</tr>
<tr>
<td><form name="form2" method="post" action="">
<label for="area">Area you are located :</label>
</form></td>
<td><input name="area" type="text" id="area" size="70"></td>
</tr>
<tr>
<td><form name="form3" method="post" action="">
Products interested in :
</form></td>
<td><table width="198">
<tr>
<td width="190"><label>
<input type="radio" name="Product" value="awnings" id="Product_0">
Awnings</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="Product" value="carport" id="Product_1">
Carport/Shadeport</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="Product" value="patio" id="Product_2">
Patio</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="Product" value="other" id="Product_5">
Other
<input type="text" name="other1" id="other1">
</label></td>
</tr>
</table></td>
</tr>
<tr>
<td><form name="form4" method="post" action="">
<label for="contactno">Contact Number :</label>
</form></td>
<td><input name="contactno" type="text" id="contactno" size="70"></td>
</tr>
<tr>
<td><form name="form5" method="post" action="">
<label for="email">Email Address :</label>
</form></td>
<td><input name="email" type="text" id="email" size="70"></td>
</tr>
<tr>
<td><form name="form7" method="post" action="">
<label for="Comments">Additional Comments :</label>
</form></td>
<td><input name="Comments" type="text" id="Comments" size="70"></td>
</tr>
<tr>
<td><form name="form8" method="post" action="">
<input type="submit" name="Submit" id="Submit" value="Submit">
</form></td>
<td><form name="form9" method="post" action="">
<input type="submit" name="reset" id="reset" value="Reset Form">
</form></td>
</tr>
</table>
This is from dreamweaver. And how do i let the form know to send via this PHP file?
If I can give you advise, don't use so many forms, just use one and set action in send.php.
send.php can look like this:
<?php
$to = "$_POST['email']";
$subject = "$_POST['subject']";
$message = "$_POST['message']";
$from = "your#email.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>