I'm working on my webservice (table) and indeed I can edit, add and delete some records with php.
If I want to add some records I got the button "add blood bank member" and this shows up a formula.
My problem
If I open the formula not all options will be shown. That means that I can see the gender, age but I do not see the first options of the formula like firstname and so on.
What I did
I thought about a CSS problem and saw on the file that the not displayed forms got the following input class:
<input class="uk-input">
I then changed in CSS the color and background-color of uk-input but it did not help.
Here is the complete form:
<h2 class="uk-modal-title">ADD Blood Bank Member</h2>
<form method="post" action="" enctype="multipart/form-data">
<div class="uk-margin">
<input class="uk-input" type="text" placeholder="First Name" name="first" required>
</div>
<div class="uk-margin">
<input class="uk-input" type="text" placeholder="Last Name" name="last" required>
</div>
<div class="uk-margin">
<input class="uk-input" type="text" placeholder="Phone Number" name="phone" required>
</div>
<div class="uk-margin">
<input class="uk-input" type="text" placeholder="Age" name="age" required>
</div>
<div class="uk-margin">
Gender<select class="uk-select" name="gender" required>
<option selected>Male</option>
<option>Female</option>
</select>
</div>
And here is an image of the formula:
What's wrong with this formula?
You can try to use JS to detect if the gender and blood group input is empty or not. First set first name last name and phone display is none, then if the input of gender and blood group is not empty then set the first name last name and phone number's display as inline-block.
Related
How can I embed http referrer in divi contact forms. I am able send only email, message text fields which are given inbetween %%field id%%. In Divi documentation they given that we need to put field id in between %% like this %%field id%%. But I am unable to add the http referrer or page url. I saw source code like this
"
<label for="et_pb_contact_name_1" class="et_pb_contact_form_label">Name</label>
<input type="text" id="et_pb_contact_name_1" class="input" value="" name="et_pb_contact_name_1" data-required_mark="required" data-field_type="input" data-original_id="name" placeholder="Name">
</p><p class="et_pb_contact_field et_pb_contact_field_1 et_pb_contact_field_last" data-id="email" data-type="email">
<label for="et_pb_contact_email_1" class="et_pb_contact_form_label">Email Address</label>
<input type="text" id="et_pb_contact_email_1" class="input" value="" name="et_pb_contact_email_1" data-required_mark="required" data-field_type="email" data-original_id="email" placeholder="Email Address">
</p><p class="et_pb_contact_field et_pb_contact_field_2 et_pb_contact_field_last" data-id="phone" data-type="input">
<label for="et_pb_contact_phone_1" class="et_pb_contact_form_label">Phone Number</label>
<input type="text" id="et_pb_contact_phone_1" class="input" value="" name="et_pb_contact_phone_1" data-required_mark="required" data-field_type="input" data-original_id="phone" placeholder="Phone Number" pattern="[0-9]*" title="Only numbers allowed.">
</p><p class="et_pb_contact_field et_pb_contact_field_3 et_pb_contact_field_last" data-id="message" data-type="text">
<label for="et_pb_contact_message_1" class="et_pb_contact_form_label">Message</label>
<textarea name="et_pb_contact_message_1" id="et_pb_contact_message_1" class="et_pb_contact_message input" data-required_mark="required" data-field_type="text" data-original_id="message" placeholder="Message"></textarea>
</p><p class="et_pb_contact_field et_pb_contact_field_4 et_pb_contact_field_last" data-id="url" data-type="input">
<label for="et_pb_contact_url_1" class="et_pb_contact_form_label">New Field</label>
<input type="text" id="et_pb_contact_url_1" class="input" value="" name="et_pb_contact_url_1" data-required_mark="not_required" data-field_type="input" data-original_id="url" placeholder="New Field">
</p>
<input type="hidden" value="et_contact_proccess" name="et_pb_contactform_submit_0">
<input type="text" value="" name="et_pb_contactform_validate_0" class="et_pb_contactform_validate_field" />
<div class="et_contact_bottom_container">
<button type="submit" class="et_pb_contact_submit et_pb_button">Send Message</button>
</div>
<input type="hidden" id="_wpnonce-et-pb-contact-form-submitted" name="_wpnonce-et-pb-contact-form-submitted" value="8b651527df" /><input type="hidden" name="_wp_http_referer" value="/data-analytics/test" />
</form>
</div> <!-- .et_pb_contact -->
</div> <!-- .et_pb_contact_form_container -->
Clearly there is hidden field but I dont know how to embed in form. Thanks
You can create new field and set display: none then just copy id of this input field.
Next create below divi code module and paste this
<script> const newInput = document.querySelector('#et_pb_contact_oboz-nazwa_0'); newInput.setAttribute('value', document.title) </script>
Where et_pb_contact_oboz-nazwa_0 - is ID of input field. You have to choose yours
document.title - is a title of page
If you want get url of page change document.title to window.location.href
And of course set this new input field to be not required
I purchased subscription addon from here, but its not working I have successfully installed it and its showing in my admin panel but when i write below code its not showing anything to me on my page.
{exp:subs:subscribe register_member="yes" plan="{segment_3}" payment_method="stripe" return="/account/subscription/%SUBS_HASH%"}
<h1>Subscribe to: {subs:plan:label}</h1>
<p>
Every <strong>{subs:plan:recurring_interval_count} {subs:plan:recurring_interval}</strong> {subs:plan:recurring_amount} {subs:plan:currency}
</p>
<hr>
{if subs:total_errors}
<ul class="errors">
{subs:form_errors}
<li>{subs:error}</li>
{/subs:form_errors}
</ul>
{/if}
<h3>Credit Card</h3>
<label>Credit Card Number</label>
<input name="card_number" type="text" value="{subs:card_number}">
<label>Name on card</label>
<input name="card_name" type="text" value="{subs:card_name}">
<label>Expires</label>
<select name="card_exp_month">{subs:month_options}</select>
<select name="card_exp_year">{subs:year_options}</select>
<label>Security Code</label>
<input name="card_cvc" type="text" value="{subs:card_cvc}" size="5">
<button type="submit">Subscribe</button>
{/exp:subs:subscribe}
I used their example code you can find it here.
please help me thanks in advance.
Your page is showing blank because page is not getting {segment_3} i.e. plan i hope you have not create any plan or if created then you have not passed them as {segment_3}. To test this thing use below code it will be helpful for you.
{exp:subs:subscribe register_member="yes" plan="gold" payment_method="stripe" return="/account/"}
<h1>Subscribe to: {subs:plan:label}</h1>
<p>
Every <strong>{subs:plan:recurring_interval_count} {subs:plan:recurring_interval}</strong> {subs:plan:recurring_amount} {subs:plan:currency}
</p>
<hr>
{if subs:total_errors}
<ul class="errors">
{subs:form_errors}
<li>{subs:error}</li>
{/subs:form_errors}
</ul>
{/if}
{if logged_out}
<h3>User Account</h3>
<label>Username</label>
<input type="text" name="username" value="">
<label>Email</label>
<input type="text" name="email" value="">
<label>Password</label>
<input type="password" name="password" value="">
<label>Password Confirm</label>
<input type="password" name="password_confirm" value="">
{/if}
<h3>Credit Card</h3>
<label>Credit Card Number</label>
<input name="card_number" type="text" value="{subs:card_number}">
<label>Name on card</label>
<input name="card_name" type="text" value="{subs:card_name}">
<label>Expires</label>
<select name="card_exp_month">{subs:month_options}</select>
<select name="card_exp_year">{subs:year_options}</select>
<label>Security Code</label>
<input name="card_cvc" type="text" value="{subs:card_cvc}" size="5">
<button type="submit">Subscribe</button>
{/exp:subs:subscribe}
make a plan named gold or abc whatever you want must put the same name at plan="plan_name" at the first line you can see it and remember for Visa cards it requires some more fields you may get fields error for this you have to use that fields you can find those fields on devdemon website.
enjoy !!!
I am making a basic new customer database with mysql and php. I would like when people click on the radio button"different mailing address" for another couple of input fields to appear for the mailing address. Im not quite sure how to handle this with inputs and not variables. Is there a way to do an if statement here is my html form code below
<form method="POST" action="insert.php">
<fieldset>
<legend>New Customer data</legend>
<label>Complete Below</label>
<div class="controls controls-row">
<input class="span4" name="firstname" type="text" placeholder="First name">
<input class="span3" name="lastname" type="text" placeholder="Last Name">
<input class="span3" name="phone" type="text" placeholder="Phone">
</div>
<div class="controls controls-row">
<input class="span4" name="address" type="text" placeholder="Address">
<input class="span2" name="city" type="text" placeholder="City">
<input class="span1" name="state" type="text" placeholder="State">
</div>
<div class="controls controls-row">
<input class="span4" name="zip" type="text" placeholder="Zip Code">
<input class="span2" name="email" type="text" placeholder="Email">
<input class="span2" name="ccemail" type="text" placeholder="cc email">
</div>
<span class="help-block">When is the customers due date monthly</span>
<label class="radio">
<input type="radio" name="duedate" id="optionsRadios1" value="1" checked>
1st of the month</label>
<label class="radio">
<input type="radio" name="duedate" id="optionsRadios2" value="15">
15th of the month
</label>
<span class="help-block">Mailing address</span>
<label class="radio">
<input type="radio" name="mailingaddress" id="optionsRadios3" value="1" checked>
Check if mailing address is the same as the service address
</label>
<label class="radio">
<input type="radio" name="mailingaddress" id="optionsRadios4" value="0">
Check if mailing address is different
</label>
<button type="submit" class="btn btn-primary">Submit</button>
</fieldset>
</form>
Using jQuery, have two inputs that are initially hidden. Once the user checks the box, '$.show()' on those two inputs. Id have a div containing two inputs, and just show or hide the div depending on whether the box is checked or not
you can try this.
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" >
</script>
<script>
$(document).ready(function(){
$("#checkme").on('change',function(){
if($("#checkme").is(":checked")){
$("input#myemail").fadeIn();
}else{
$("input#myemail").fadeOut();
}
});
});
</script>
</head>
<body>
show: <input type="checkbox" id="checkme" /><br />
<input type="text" id="myemail" hidden />
</body>
</html>
I have a large amount of input fields. How can I pass the values into an array so I can pass the array from one page to another?
example:
<input type="text" value=<?php $arry = "compName" ?> placeholder="Company Name" />
Is this legal? How can I do this properly?
EDIT:
In my page, I have "add" and "delete" buttons that will add/delete more input fields. I also have a "preview" button at the bottom. User will add/delete before hitting preview. Preview will collect all input and will call the next page. So the amount of field is unknown.
Here's what my code/markup looks like:
<div class="panel" style="width: 98%; margin:0 auto">
<div class="row">
<div class="large-6 columns">
Advertiser Info: <hr>
<input type="text" value="compName" placeholder="Company Name" />
<input type="text" value= "adEmail" placeholder="Email" />
<input type="text" value="adContName" placeholder="Contact Name" />
<input type="text" value="adPhone" placeholder="Phone # (NO DASHES)" />
<input type="text" value="adStreet" placeholder="Street Address" />
<input type="text" value="adCity" placeholder="City" />
<input type="text" value="adState" placeholder="State/Provice" />
<input type="text" value="adZip" placeholder="Zip/Postal Code" />
<input type="text" value="adCountry" placeholder="Country" />
</div>
<div class="large-6 columns">
Billing Info: <hr>
<input type="text" value="bEmail" placeholder="Email" />
<input type="text" value="bContName" placeholder="Contact Name" />
<input type="text" value="bPhone" placeholder="Phone # (NO DASHES)" />
<input type="text" value="bStreet" placeholder="Street Address" />
<input type="text" value="bCity" placeholder="City" />
<input type="text" value="bState" placeholder="State/Provice" />
<input type="text" value="bZip" placeholder="Zip/Postal Code" />
<input type="text" value="bCountry" placeholder="Country" />
</div>
</div>
</div>
So when the user hits add and EXACT copy of above code will be made.
With that said, I want to be able to use PHP arrays for html values to pass. How can I set my inputs so that I can do this?
You can do some tweaks like:
Using input type elements as array elements.
So that:
<input type="text" name="elem[name]" value="<?php echo $YOUR_VALUE;?>"
<input type="text" name="elem[class]" value="<?php echo $YOUR_VALUE;?>"
<input type="text" name="elem[marks]" value="<?php echo $YOUR_VALUE;?>"
So that the variables are you are posting should be less.
In this case, you are posting only one variable instead of three.
Use Jquery to get all the values of input fields and make a json object of {input_name:value} or array variable of key value and then pass it in argument.
var key_value = {};
$('input').each(function(){
key_value[$(this).attr('name')]= $(this).val();
})
alert(JSON.stringify(key_value));
Now you have an object with field name as key and its value.
Alright here is what I am attempting to do. I have a form written in HTML. It has a few HTML5 elements to it though. What I would like to happen, is when the user fills out all the required fields (validated with PHP and some HTML5) and submits the form, it will export to an existing XML file. The form also uses AJAX to validate as the user fills out the fields, and to validate the form as a whole (once submitted) without reloading my page.
The XML file is just a framework of empty tags set up to receive the information from form submissions, built upon a schema (I made) to restrict it to certain values and what not. I would also need to be able to have a script to validate the new XML values against the schema to make sure all values are valid, and if not return an error message.
The XML Schema validation is as close as possible to the PHP validation with a few character amount limits added in here and there.
If you need me to post the schema for the XML file in order to give a more specific answer then I will upon request.
XML Framework:
<form>
**<!-- First Name -->**
<fname></fname>
<!-- Last Name -->
<lname></lname>
<!-- Phone Number -->
<phone></phone>
<!-- Email -->
<email></email>
<!-- Website -->
<website></website>
<!-- Subject -->
<subject></subject>
<!-- Message -->
<message></message>
</form>
HTML Form:
<form method="post" action="php/validator.php" name="contactform" id="contactform" autocomplete="on">
<fieldset>
<legend>Contact Details</legend>
<div>
<label for="fname" accesskey="F">Your First Name*</label>
<input name="fname" type="text" id="name" placeholder="Enter your first name" tabindex="1" required />
</div>
<div>
<label for="lname" accesskey="L">Your Last Name*</label>
<input name="lname" type="text" id="name" placeholder="Enter your last name" tabindex="2" required />
</div>
<div>
<label for="email" accesskey="E">Email*</label>
<input name="email" type="email" id="email" placeholder="myEmail#example.com" pattern="^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)#([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$" tabindex="3" required />
</div>
<div>
<label for="phone" accesskey="P">Phone <small>(optional)</small></label>
<input name="phone" type="tel" id="phone" size="12" placeholder="555-555-5555" tabindex="4" />
</div>
<div>
<label for="website" accesskey="W">Website <small>(optional)</small></label>
<input name="website" type="url" id="website" placeholder="www.yourWebDomain.com" tabindex="5" />
</div>
</fieldset>
<fieldset>
<legend>Your Comments</legend>
<div>
<label for="subject" accesskey="S">Subject*</label>
<select name="subject" id="subject" tabindex="6" required="required">
<option value=""></option>
<option value="Support">Support</option>
<option value="Sale">Sales</option>
<option value="Bug">Report a bug</option>
<option value="Other">Other</option>
</select>
</div>
<div>
<label for="comments" accesskey="C">Comments*</label>
<textarea name="comments" cols="40" rows="3" id="comments" class="comments" placeholder="Enter your comments" spellcheck="true" required tabindex="7"></textarea>
</div>
</fieldset>
<input type="submit" class="submit" id="submit" value="Submit" tabindex="9" />
</form>
After validation use PHP to capture the form fields, wrap them in XML elements, then save it.
e.g.
<form>
<fname><?php=$_REQUEST['fname']?></fname>
<lname><?php=$_REQUEST['lname']?></lname>
...
..
</form>
No sense in double validation either, with one slightly different than the other. It would be annoying for the user to submit their data successfully but somehow get rejected in the backend without warning. DOMDocument is a little overkill as well.
PHP contains a class called DOMDocument specifically for the purpose of building, altering, importing and exporting XML data. If you are familiar with constructing DOM elements in Javascript, it is the same idea. Create your DOMDocument, then create each element and append those elements to DOMDocument (or that element's parent) after you've made them. After you're done there, use the save function to write it to a file.