проверьте этот пример ниже:
declare @projects varchar(max) = 'Project1;Project2;Project3'
Declare @table_1 table
(Id int ,
project varchar(15))
Insert @table_1 values (001, 'project1')
Insert @table_1 values (002, 'project2')
Insert @table_1 values (003, 'project3')
Insert @table_1 values (035, 'project35')
Insert @table_1 values (036, 'project36')
Insert @table_1 values (037, 'project37')
Declare @table_2 table
(Id int ,
RelatedProject_ID int)
Insert @table_2 values (001, 035)
Insert @table_2 values (002, 036)
Insert @table_2 values (003, 037)
Insert @table_2 values (004, 038)
Insert @table_2 values (005, 039)
;with cte as (
SELECT LTRIM(RTRIM(m.n.value('.[1]','varchar(8000)'))) AS projects
FROM
(
SELECT CAST('' + REPLACE(@projects,';',' ') + ' ' AS XML) AS x
)t
CROSS APPLY x.nodes('/XMLRoot/RowData')m(n)
)
select t1m.project
from @table_1 t1
join @table_2 t2 on t2.id=t1.id
join @table_1 t1m on t1m.id=t2.RelatedProject_ID
join cte cte on t1.project=cte.projects
Попробуйте это -
var priceInput = document.getElementById("input-price");
priceInput.addEventListener("input", representValue)
function representValue(){
var numOfChars = priceInput.value.length;
var magicSpan = document.getElementById("magic-value");
value = 100 + (numOfChars*10);
magicSpan.textContent = value;
}
<span id="magic-value">100</span>
<input id="input-price" type="text">
Вы можете попробовать следующий способ:
var length = $('#input-price').val().length;
$('#input-price').on('input', function(){
var n = Number($('#spanNumber').text());
if(length < $('#input-price').val().length){
$('#spanNumber').text(n + 10);
length++
}
else{
$('#spanNumber').text(n - 10);
length--
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input id="input-price"/>
<span id="spanNumber">100</span>