A
A
Anton2017-08-25 13:02:51
Google Sheets
Anton, 2017-08-25 13:02:51

How to substitute values ​​from a table into a form to send to the server?

There is a plate with cells
. The cell contains a number of parameters ID of the element, the Symbolic code of the property and the value of this property, plus, depending on the value, the inscription "Free" or "Busy" is displayed.
Now visually it looks like this: 156847Q112600FREE
where 15684 is ID, Q11 is property, 2600 is value
We need to make these parameters passed to the form below for API
Here is the code (but it's not a form yet)

<?
$ELEMENT_ID = 156847;  // код элемента
$PROPERTY_CODE = "Q11";  // код свойства
$PROPERTY_VALUE = "2600";  // значение свойства

// Установим новое значение для данного свойства данного элемента
CIBlockElement::SetPropertyValuesEx($ELEMENT_ID, false, array($PROPERTY_CODE => $PROPERTY_VALUE));

?>

How to make it so that when you click on a table cell, the parameters from the cell (all cells are individual) are substituted into the API code?
In general, I will describe the task as follows:
You need to create a form at the bottom of the full name, Phone, Mail, Time and the "Sign up" button
A person fills out the form, pokes in the plate on top for the time "Free", the data from this cell enters the entry form in the "stealth" mode. When you click on "Sign up" from the form, two APIs are triggered. The
first API changes the status from Free to busy (the code above is published)
The second API creates an infoblock element and contains the full name, Phone number ... and so on AND the Time that should be taken from the table.
Partially I will do it myself, at least I will try.
But how to implement the substitution from the table in the API code?
Here is the table
<td>
<?
if ($person['Q11'] == 'N') {echo ($ELEMENT_ID).($PROPERTY_CODE).($PROPERTY_VALUE).'<span style="color:green">'."СВОБОДНО".'</span>';} 
else { echo '<span style="color:red">'."ЗАНЯТО".'</span>';}?>
</td>

Need $ELEMENT_ID $PROPERTY_CODE $PROPERTY_VALUE
Substitute in the form and send to the server

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Artamonov, 2017-08-25
@ArtamonovDenis


156847Q112600FREE
where 156847 is ID, Q11 property, 2600 value
if it is not possible to set your own value string format,
then all that remains is to parse the value string and get the necessary data,
everything up to Q is $ELEMENT_ID
if in Q11 - the number of characters after Q is always = 2, then we count 2 characters from Q - it will be $ PROPERTY_CODE.
or if the number of characters is not equal to 2 (i.e. Q11 can change), then initially you need to get all the property codes and check the code in the line, if found, then write the
remaining line to $PROPERTY_CODE = $PROPERTY_VALUE
after receiving all the data - send the request api where the function meets you
CIBlockElement::SetPropertyValuesEx($ELEMENT_ID, false, array($PROPERTY_CODE => $PROPERTY_VALUE));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question