html4d

4D working with HTML select


Working with a html select element with 4D as can be seen below. On load, If user has a bankID, I wasn't able to make the chosen bank as selected, despite having it on memory already. 4D is on version 16.3. It seems like the browser is ignoring the 4DIF altogether.

<select style="width:100%;" id="bank_list" class="form-control input-sm" tabindex="0" name="bank">
<option></option>
<!--4DLOOP [Bank]-->
<option value="<!--4DVAR [Bank]ID-->" <!--4DIF ([User]BankID=[Bank]ID)--> selected="selected" <!--4DENDIF--> ><!--4DVAR [FinvoiceFactoring]PartyName -->
</option>
<!--4DENDLOOP -->


Solution

  • when you make a 4DLOOP on a table ( Bank ) the code inside the 4DLOOP-4DENDLOOP cycle on every record of current selection.

    So, when you write "IF [table]Field = [table]Field " you'll have the same values. The solution is to have a variable where to save the current BankId.

    Beware: You have to use Process Variable, not Interprocess (identified with <> prefix), because this last type is shared among all web processes: so if you'll have two user they'll have the same variable content!