I got Excel with 4 columns: Complete name, celphone, city, and comments. And I have HTML/PHP form to send ADF format email.
At the moment I'm copying each cell and paste in each form field. How I can improve my code to copy a row from Excel and paste it in 1 time on my form fields?
I mean I need to detect /n
to change form field or something like that? This is part of my actually form
<div class="col-sm-3">
<div class="form-group">
<label for="customer_contact_prospect" class="control-label">Nombre completo del prospecto <strong class="text-danger">*</strong></label>
<input type="text" id="customer_contact_prospect" name="customer_contact_prospect" class="form-control required">
</div>
</div>
</div>
You can copy and paste a range of data from excel into a text area. The information you've given is insufficient to be used in a mailer, but here's how to extract the excel information:
HTML Form input:
<textarea name="excel_info"></textarea>
Receiving PHP script:
<?php
$raw_data = $_POST['excel_info'];
$name = array();
$rows = explode("
", $raw_data);
foreach($rows as $row) {
$column = explode("\t", $row);
$name[] = $column[0];
}
// iterate through $name array and do whatever you need with the names
// note: no data cleansing has been done; you are responsible for cleaning your own data.
If you're wanting to grab a specific column using javascript, an example using the jquery library for javascript:
var temp = ('#customer_contact_prospect').val().split("\t");
var name = temp[0]; // assuming name is the first column
// optionally put it in a hidden input id="name"
$('#name').val(name);