Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

dynamic table using buttons

sono82sono82 Member Posts: 5
below is my coding..
so far, the coding can be run, but now i want to upgrade the program so that after the user enter the table, the user can manipulate the data in the table to create a logical explanation from the table
for instance, the default logic that will be created from 3 rows of table is

"1 AND 2 AND 3 AND "
i want to change if user click the checkbox of any data in the table, then if they click on the or selection,the data would change like ( according to the checked checkbox)

--assuming the data checked is 1 & 2
1 OR 2 AND 3 AND

--assuming the data checked is 1,2,3
(1 OR 2 OR 3) AND

--assuming the data checked is 1 & 3
(1 AND 2) OR 3 AND

P:S the brackets will be auto added according to the or selected.
Please anyone who can help me, i really need the solution for this problem.. :( been doing it for ages now, still cannot solve it.. :((









rule = new Array(5);
//todo: find how to replace this implementation

for (i=0;i<100;i++)
{
rule[i] = new Array(3);
}
var last_row = 0;
var vcount =1;

function insert_new_rule()
{
txt = document.forms[0].selTerms.options[ document.forms[0].selTerms.selectedIndex ].text
txt2 = document.forms[0].selConds.options[ document.forms[0].selConds.selectedIndex ].text
txt3 = document.forms[0].txtValue.value
//alert (txt);

var x=document.getElementById('tblRule').insertRow(1)
var w=x.insertCell(0)
var v=x.insertCell(1)
var y=x.insertCell(2)
var z=x.insertCell(3)
var a=x.insertCell(4)
w.innerHTML="<input type=checkbox name=checkbox onclick=test() value="+vcount+">"
v.innerHTML=vcount
y.innerHTML=txt
z.innerHTML=txt2
a.innerHTML=txt3

newvcount = vcount++
countAND = " AND "

count=document.forms[0].txtLogic.value

count=count + newvcount + countAND

document.forms[0].txtLogic.value=count
}








       
Terms
Conditions
Value

 

Please Choose
Service_Number
Dialed_Digits
To_Number
Country_Code
Charge
Call_Duration
Equipment_Num
User_Group
Pin_Number

is
is not

 



RULE NO
FIELD
CONDITION
VALUE
 
 
 
 
 






Comments

  • CyGuyCyGuy Member Posts: 312
    [green]upon all outward appearences this appears to be a logic problem, but without knowing the result you wish to achieve, it is difficult to derive a solution. reviewing the code, it seems as if you have to address a grouping problem before you can procede... why not give the array a third dimension and call each seperate index a page. now you can seperate all OR on a page with AND between pages... like so:
    rule[0][0][1..3]OR
    rule[0][1][1..3]OR
    rule[0][2][1..3]AND
    rule[1][0][1..3]OR
    rule[1][1][1..3]AND
    rule[2][0][1..3]AND
    the logic should read a null as indication to perform ANDoperation, and increment the 3rd while reset the 2nd index... of course there will be regrouping as elements get shifted(during btnORselection event) to different pages - they should be removed from the previous page.
    Good Luck[/green]



    : below is my coding..
    : so far, the coding can be run, but now i want to upgrade the program so that after the user enter the table, the user can manipulate the data in the table to create a logical explanation from the table
    : for instance, the default logic that will be created from 3 rows of table is
    :
    : "1 AND 2 AND 3 AND "
    : i want to change if user click the checkbox of any data in the table, then if they click on the or selection,the data would change like ( according to the checked checkbox)
    :
    : --assuming the data checked is 1 & 2
    : 1 OR 2 AND 3 AND
    :
    : --assuming the data checked is 1,2,3
    : (1 OR 2 OR 3) AND
    :
    : --assuming the data checked is 1 & 3
    : (1 AND 2) OR 3 AND
    :
    : P:S the brackets will be auto added according to the or selected.
    : Please anyone who can help me, i really need the solution for this problem.. :( been doing it for ages now, still cannot solve it.. :((
    :
    :
    :
    :
    :
    :
    :
    :
    :
    : rule = new Array(5);
    : //todo: find how to replace this implementation
    :
    : for (i=0;i<100;i++)
    : {
    : rule[i] = new Array(3);
    : }
    : var last_row = 0;
    : var vcount =1;
    :
    : function insert_new_rule()
    : {
    : txt = document.forms[0].selTerms.options[ document.forms[0].selTerms.selectedIndex ].text
    : txt2 = document.forms[0].selConds.options[ document.forms[0].selConds.selectedIndex ].text
    : txt3 = document.forms[0].txtValue.value
    : //alert (txt);
    :
    : var x=document.getElementById('tblRule').insertRow(1)
    : var w=x.insertCell(0)
    : var v=x.insertCell(1)
    : var y=x.insertCell(2)
    : var z=x.insertCell(3)
    : var a=x.insertCell(4)
    : w.innerHTML="<input type=checkbox name=checkbox onclick=test() value="+vcount+">"
    : v.innerHTML=vcount
    : y.innerHTML=txt
    : z.innerHTML=txt2
    : a.innerHTML=txt3
    :
    : newvcount = vcount++
    : countAND = " AND "
    :
    : count=document.forms[0].txtLogic.value
    :
    : count=count + newvcount + countAND
    :
    : document.forms[0].txtLogic.value=count
    : }
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    : : : : : : : :
    : : : : : : : :
    : : : : : : : :
    : : : : : : : : :
    : : : : : : :
    : : : : : :
    : : : : : : : :
    : : : : : : : : :
        
    Terms
    :
    Conditions
    Value

    :
     

    : Please Choose
    : Service_Number
    : Dialed_Digits
    : To_Number
    : Country_Code
    : Charge
    : Call_Duration
    : Equipment_Num
    : User_Group
    : Pin_Number
    :

    : is
    : is not
    :

    :
     

    :
    :
    : RULE NO
    : FIELD
    : CONDITION
    : VALUE
    :
     
    :
     
     
    :
     
     
    :
    :
    :
    :
    :
    :
    :
    :

Sign In or Register to comment.