Click here to Skip to main content
15,898,760 members

Comments by Sums Mohs Eds (Top 5 by date)

Sums Mohs Eds 2-Dec-15 9:16am View    
Oh am so sorry, with jquery suppose the structure is
<select multiple="true">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
</select>

then it can be selected like below
$("select option[value=2]").attr("selected", true);

incase if it is multiple selection like i have mentioned it in html code, you can repeat the values as shown below.
$("select option[value=2]").attr("selected", true);
$("select option[value=4]").attr("selected", true);
Sums Mohs Eds 30-Nov-15 5:37am View    
Yes for that in the header place a checkbox and in its event change you will have to do what is refered in the link provided in the solution.
Sums Mohs Eds 27-Nov-15 7:24am View    
What is the output you are getting with the query you have mentioned here?
Sums Mohs Eds 27-Nov-15 5:04am View    
Thats what i have mentioned at the start of the solution, if the ID was accordingly you would have. That is, you should be grouping it.

For Example,

SNo NetAmt
1 0
2 0
3 -10761
3 0
4 38834
4 0
4 0
5 -100000
5 0
6 80000
7 28457
7 0
7 0
7 0
7 0

With the above grouping we can still try using CTE.

But then since you have tried using while loop, below is the modified solution which works.


DECLARE @totalRecords INT
DECLARE @I INT

SELECT @I = 1
SELECT @totalRecords = COUNT(sno) FROM tmp1
declare @preval decimal(8,2)
set @preval=0
WHILE (@I <= @totalRecords)
BEGIN

declare @curval decimal(8,2)
declare @nextval decimal(8,2)

select @curval=netamt from tmp1 where sno=@I


if(@preval<>@curval)
Begin
If (@curval=0)
Begin
update tmp1 set netamt=@preval where sno=@I
End
End

if(@curval<>0)
Begin
Select @preval=@curval
End

set @I=@I+1;
END
Sums Mohs Eds 25-Nov-15 7:48am View    
So, I would like to know following details. If at all you are deleting or updating on what basis or depending on what columns you would do that. I mean the where condition will have which columns?