I am developing this form that has the functionality that allow the user to add an input field in the form. Here's the input field that will be added:
<li>
<input type="text" name="appliSkill[]" placeholder="Adobe Photoshop" >
</li>
I am using contact form 7 plugin to handle the the submission and email process of this for.
For a simple input name, we can easily call the [input-name] in the mail section of the cf7 to pass the value of that field and send it through email.
I would like to do the same and get all the value of appliSkill[] and pass it to the email. Assuming the form would be look like this after the user add more fields:
<ul>
<li>
<input type="text" name="appliSkill[]" placeholder="Adobe Photoshop" >
</li>
<li>
<input type="text" name="appliSkill[]" placeholder="Adobe Photoshop" >
</li>
<li>
<input type="text" name="appliSkill[]" placeholder="Adobe Photoshop" >
</li>
<li>
<input type="text" name="appliSkill[]" placeholder="Adobe Photoshop" >
</li>
</ul>
How can i do that?
Thank you in advance :)
Related
A long time ago I used MailChimp (free account) options to create a Signup Form:
https://www.publictalksoftware.co.uk/newsletter-signup/
The problem is that:
The user can hit Subscribe without selecting any of the newsletter categories.
This makes their signing up pointless.
Does any one know how to improve the MailChimp signup form to force the user to check a field to select atleast 1 option?
This is the current HTML for the section of interest:
<div class="mc-field-group input-group">
<strong>Which Theocratic Software Are You Interested In? </strong>
<ul><li>
<input type="checkbox" value="1" name="group[20257][1]" id="mce-group[20257]-20257-0">
<label for="mce-group[20257]-20257-0">Meeting Schedule Assistant</label>
</li>
<li>
<input type="checkbox" value="2" name="group[20257][2]" id="mce-group[20257]-20257-1">
<label for="mce-group[20257]-20257-1">Public Talks</label>
</li>
<li>
<input type="checkbox" value="4" name="group[20257][4]" id="mce-group[20257]-20257-2">
<label for="mce-group[20257]-20257-2">Visits Rota</label>
</li>
<li>
<input type="checkbox" value="8" name="group[20257][8]" id="mce-group[20257]-20257-3">
<label for="mce-group[20257]-20257-3">Cross Platform (iOS / macOS / Android)</label>
</li>
<li>
<input type="checkbox" value="16" name="group[20257][16]" id="mce-group[20257]-20257-4">
<label for="mce-group[20257]-20257-4">Other Software</label>
</li>
</ul>
<span id="mce-group[20257]-HELPERTEXT" class="helper_text">Please select atleast one </span>
</div>
I notice that the other input fields have the required parameter specified and in this case the logic is a list iof input fields, so it inself none can have the required property set else all will need to be ticked.
But surely there was be a way to custom validate and check all these fields to make sure atleast one is ticked, and tell the user?
I'm trying to create a form on a Cargo site, but they don't allow anywhere for .php files. I want the form to send an email to me upon the "submit" button being clicked. "mailto:" doesn't work, by the way.
Here's the form right now. I've tried adding an action to the form, but obviously I can't link a .php file:
<form>
<ul class="form-style-1">
<li><label>Full Name <span class="required">*</span></label><input type="text" name="field1" class="field-divided" placeholder="First"> <input type="text" name="field2" class="field-divided" placeholder="Last"></li>
<li>
<label>Email <span class="required">*</span></label>
<input type="email" name="field3" class="field-long">
</li>
<li>
<label>Subject</label>
<select name="field4" class="field-select">
<option value="Advertise">Advertise</option>
<option value="Partnership">Partnership</option>
<option value="General Question">General</option>
</select>
</li>
<li>
<label>Your Message <span class="required">*</span></label>
<textarea name="field5" id="field5" class="field-long field-textarea"></textarea>
</li>
<li>
<input type="submit" value="Submit">
</li>
</ul>
</form>
If anyone could suggest a workaround, I'd be so grateful!
Here is the snippet of html code.....
1)After checking each check box the value's is posting to the database.
2)But the problem is when i checked other, i need to take the value of the text box and it is posting the value of the checkbox instead of the textbox value
but i don't know where i did mistake...
<form action="purchase.php" name="form1" id="form1" method="POST">
<ul class="n_ul"> <span>*</span>
What is your Primary goal?
<br>
<br>
<li>
<input name="goal" id="goal" value="Add a popular customer service to attract/retain more customers"
type="checkbox">
</li> <span>*</span>
Popular customer Services
<br>
<br>
<li>
<input name="goal" id="goal" value="Add a turnkey revenue sources for my location(s)"
type="checkbox">
</li> <span>*</span>
trunkey revenue source
<br>
<br>
<li>
<input name="goal" id="goal" type="checkbox" value="other">
</li> <span>*</span>
Other (Please specify below)
<br>
<br>
<input name="other" id="goal" type="text" class="new">
</ul>
<input type="submit" name=submit value="submit">
</form>
Any suggestions are acceptable....
Try something like
$_POST['goal'] = ($_POST['goal']=='other') ? $_POST['other'] : $_POST['goal'];
This will overwrite the value of goal with the value of other only when the 'other' radio is ticked
Also id attributes of html elements should be unique on the page
EDIT
Your question is a little vague. It seems like you may want the form to submit when a checkbox button is clicked.
If this is the case the other field will be unlikely to be filled as the form will often be submitted before the user gets to populate it
Try adding a button or input to submit the form
Like this
<button type="submit">Submit</button>
You can check the value of your checkbox, and if it equals to other, you can grab your value from textbox. Do it following way:
if (isset($_POST['goal']) && $_POST['goal'] == 'other')
{
// do something with $_POST['other']
}
Try this
<form action="" name="form1" id="form1" method="POST">
<ul class="n_ul"> <span>*</span>
What is your Primary goal?
<br>
<br>
<li>
<input name="goal[]" id="goal" value="Add a popular customer service to attract/retain more customers"
type="checkbox">
</li> <span>*</span>
Popular customer Services
<br>
<br>
<li>
<input name="goal[]" id="goal" value="Add a turnkey revenue sources for my location(s)"
type="checkbox">
</li> <span>*</span>
trunkey revenue source
<br>
<br>
<li>
<input name="goal[]" id="goal" type="checkbox" value="other">
</li> <span>*</span>
Other (Please specify below)
<br>
<br>
<input name="other" id="goal" type="text" class="new">
</ul>
<input type="submit" name=submit value="submit">
</form>
<?php
$other="";
$goal=$_REQUEST['goal'];
if(in_array("other", $goal)){
$other=$_REQUEST['other'];
}
echo $other;
?>
If I had some coding as follow.
<form method="POST" action="localhost/carts/delete">
Item 1
Item 2
Item 3
</form>
And I like to post to a form with some hidden value to indicate which Item is clicked, how to do that???
Thanks.
Edited Text.
Thanks for so many useful suggestions.
I actually use Laravel 4 rather than PHP, my Laravel code produced this HTML
<form ...>
<ul>
<li>
<h1>Key: 1 </h1>
<input name="cart_id" type="hidden" value="1">Delete
</li>
<li>
<h1>Key: 2 </h1>
<input name="cart_id" type="hidden" value="2">Delete
</li>
<li>
<h1>Key: 6 </h1>
<input name="cart_id" type="hidden" value="6">Delete
</li>
<li>
<h1>Key: 7 </h1>
<input name="cart_id" type="hidden" value="7">Delete
</li>
</ul>
</form>
So, when I clicked on any items, I got 7 which is the last value of cart_id, how to place at the right place, in JavaScript???
Create a hidden element inside the form:
<form method="POST" action="localhost/carts/delete">
<input type="hidden" name="myValue" value="" id="myValue"/>
Item 1
Item 2
Item 3
</form>
Then on click over any link (a) change its value and submit the form.
$('a').click(function(e){
//preventing the default link redirection
e.preventDefault();
$('#myValue').val($(this).data('value'));
$(this).closest('form').submit();
});
Use a hidden input field like:
<input type="hidden" value="hidden value" name="id"/>
This box is not visible in your page.
Use input fields instead.
<form method="POST" action="localhost/carts/delete">
<input type="submit" value="Item 1" name="whichitem[]" />
<input type="submit" value="Item 2" name="whichitem[]" />
<input type="submit" value="Item 2" name="whichitem[]" />
</form>
Then in PHP you can retrieve the clicked value like this:
$_POST["whichitem"]
If you are worried about the styling, simply add it in your css:
input[type="submit"]{
//style
}
I have set up a PHP form for a competition for users to enter all information to be stored in a database. I used a NetTut+ tutorial to do so.
I've got the form submitting to the database as required, but with so many additional questions being asked, I would like to split the form into two separate sections. Obviously the first page would say continue to the next step before the second step allowing for the form to be submitted to the database.
The content that the user sees should be split, but should all be a part of the same form. Step 1 > Step 2 before submission.
Would anyone know of or recommend any methods to do this?
I've attached the code below.
<form method="post" action="">
<fieldset>
<ul>
<li>
<label for="code">Entry Code On-Pack</label>
<input type="text" name="code" />
</li>
<li>
<label for="name">Name</label>
<input type="text" name="name" />
</li>
<li>
<label for="email">Email</label>
<input type="text" name="email" />
</li>
<li>
<label for="addressone">Address</label>
<input type="text" name="addressone" />
</li>
<li>
<label for="addressone"> </label>
<input type="text" name="addresstwo" />
</li>
<li>
<label for="addressone"> </label>
<input type="text" name="addressthree" />
</li>
<li>
<label for="telephone">Telephone</label>
<input type="text" name="telephone" />
</li>
<li>
<label for="dob">Date of Birth</label>
<input name="dob" type="text" value="[dd/mm/yy]" />
</li>
<li>
<label for="q1">Where have you seen Cookstown advertised?</label><br />
<input type="checkbox" name="q1cb1" /><label for="q1cb1">Magazines</label><br />
<input type="checkbox" name="q1cb2" /><label for="q1cb2">Billboards</label><br />
<input type="checkbox" name="q1cb3" /><label for="q1cb3">Television</label><br />
<input type="checkbox" name="q1cb4" /><label for="q1cb4">Radio</label><br />
<input type="checkbox" name="q1cb5" /><label for="q1cb5">Online</label><br />
<input type="checkbox" name="q1cb6" /><label for="q1cb6">Public Transport</label><br />
<input type="checkbox" name="q1cb7" /><label for="q1cb7">Bus Stops</label><br />
</li>
<li>
<label for="q2">How well do you remember those advertisments?</label><br />
<input type="radio" name="q2" value="VeryWell"/><label for="q1cb1">Very well</label><br />
<input type="radio" name="q2" value="FairlyWell"/><label for="q1cb2">Fairly well</label><br />
<input type="radio" name="q2" value="FewDetails"/><label for="q1cb3">A few details</label><br />
<input type="radio" name="q2" value="NotAtAll"/><label for="q1cb4">Not at all</label><br />
</li>
<label for="tc">Do you accept the terms and conditions</label>
<input type="checkbox" name="tc" class="styled" />
</li>
<li> </li>
<li>
<input type="submit" value="Enter Competition" class="large blue button" name="signup" />
</li>
</ul>
</fieldset>
</form>
Use sessions mechanism to store 1 step data
You could pass them to page two and then put them in as hidden variables. You could also use session variables.
example with hidden fields
Sessions are usually the preferred way to do this, but hidden form fields would work just as well.
It's pretty easy to do - after the first submission, store the values into the session - validate them first if you like, it's probably a good idea to do so in fact. Then go to the next page, and once submitted, validate the second bunch of answers and put them into the database.
Hidden form fields work too, but I prefer the session-based approach.
Good luck!
One other option would be to put the additional fields in a hidden div on the same page and use javascript to show them once the first set have been completed. The advantage for you is that it keeps your form processing simpler. Also for your users, they won't have a round trip to the server to get the other part of the form.
This, of course, requires that your users have javascript turned on. The best practice would be to show all fields on the same page by default, and then use JS to hide the second batch before the page renders.