Page 1 of 3 123 Last
  • Jump to page:
    #1
  1. Contributing User
    ASP High Scholar (3500 - 3999 posts)

    Join Date
    Jul 2005
    Location
    Oxford UK
    Posts
    3,897
    Rep Power
    992

    Add row on onclick event


    hi...
    i m developing form which will enter cancellation rate for each product..
    Cancellation Rate Details
    has one table where Cancellation Type is one dropdown than 3 text boxes From Days ,To Days ,Cancellation Charges and one button ADD..when i click on this button add than it will add all this details below of this table in a row..for first time it is working...now again if i click add button than it will add all details below to the first row added....if i m trying to add details which is already addead than it will not add those details.
    Code:
    <html>
    <head>
    <title></title>
    <link href="/icici/client/iciciom.css" rel="stylesheet" type="text/css">
    <SCRIPT LANGUAGE=JavaScript >
    function trim(s) 
    { 
        return s.replace(/^\s+/,"").replace(/\s+$/,""); 
    } 
    
    function showButton()
    {
    	retval=xmldata('GetChkRateDuplicate',document.forms[0].Field_4.value)
    		window.clipboardData.setData("text",retval)
    		if (retval == 'Yes')
    		{
    			alert("Cancellation Rate Details already entered for this product");
    			return false;
    		}
    
    	
    /*	var rootNode = DS_xmlTbl1.XMLDocument.selectSingleNode('root');
    	if(!rootNode.hasChildNodes()) 
    	{
    		alert("Please Enter Cancellation Rate Details");
    		return false;
    	}		 
    
    	document.all._portal_publish_button.click();
    	return true;
    }*/
    
    function check_add_canceltype()
    {
    	var product_cd= document.forms[0].Field_4.value;
    	var canc_type = document.forms[0].cbotype.value;
    	var from_day  =parseInt(trim(document.forms[0].fromdays.value));
    	var to_day    = parseInt(trim(document.forms[0].todays.value));
    	var canc_per  = parseInt(trim(document.forms[0].cancelpercentage.value));
    	
    	
    	if (document.forms[0].Field_4.options[document.forms[0].Field_4.selectedIndex].value == '1')
    	{
    		alert ('Please select Product');
            document.forms[0].Field_4.focus();
    		return false;
    	}
    	
    	if (document.forms[0].cbotype.options[document.forms[0].cbotype.selectedIndex].value == '')
    	{
    		alert ('Please select Cancellation Type');
    		document.forms[0].cbotype.focus();
    		return false;
    	}
    	
    	if (trim(document.forms[0].fromdays.value)== "")
    	{
    		alert ('Please enter From Days');
    		document.forms[0].fromdays.focus();
    		return false;
    	}
    	
    	if (trim(document.forms[0].todays.value) =="" || trim(document.forms[0].todays.value) == 0)
    	{
    		alert ('Please enter To Days');
    		document.forms[0].todays.focus();
    		return false;
    	}
    	
    	if (trim(document.forms[0].fromdays.value) == trim(document.forms[0].todays.value))
    	{
    		alert ('From Days and To Days cannot the same');
    		return false;
    	}
    	
    	if (trim(document.forms[0].fromdays.value) > trim(document.forms[0].todays.value))
    	{
    		alert ('From Days cannot be greater than To Days');
    		return false;
    	}
    		
    	if (trim(document.forms[0].cancelpercentage.value) == '' || trim(document.forms[0].cancelpercentage.value) == 0)
    	{
    		alert ('Please enter Cancellation charges');
    		document.forms[0].cancelpercentage.focus();
    		return false;
    	}
    	
    	if (trim(document.forms[0].fromdays.value)  > 1097)
    	{
    		alert ('From Days cannot be greater than 1096');
    		document.forms[0].fromdays.focus();
    		return false;
    	}
    
    	if (trim(document.forms[0].todays.value) > 1097)
    	{
    		alert ('To Days cannot be greater than 1096');
    		document.forms[0].todays.focus();
    		return false;
    	}
    	document.getElementById("divxmltbl1").style.display="block";
        document.forms[0].Field_6.value =document.forms[0].cbotype.value;
    	document.forms[0].Field_7.value=document.forms[0].fromdays.value;
    	document.forms[0].Field_8.value=document.forms[0].todays.value; 
    	document.forms[0].Field_9.value =document.forms[0].cancelpercentage.value
    	
    		
    	document.forms[0].cbotype.value = '';
    	document.forms[0].fromdays.value = '';
    	document.forms[0].todays.value = '';
    	document.forms[0].cancelpercentage.value = '';
    	
    	 document.forms[0].Field_11.value = document.forms[0].Field_4.value;
    			
    	return true;
    }
    
    
    
    
    
    
    
    function xmldata(functionname,parameters)
    {
    	parameters = parameters.replace(/ /g,"$");
    	parameters = parameters.replace(/&/g,"!!");		
    	var DataToSend = ""	
    	if (parameters != "")
    	{		
    		DataToSend = "id=" + functionname;		
    		DataToSend = DataToSend + "@" + parameters;		
    	}
    	else
    	{
    		DataToSend = "id=" + functionname;
    	}
    	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    	xmlhttp.Open("POST","/icici/client/HealthMasterXML.asp",false);
    	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    	xmlhttp.send(DataToSend);
    	return xmlhttp.responseText;
    }
    
    </Script>
    
    
    
    
    <SCRIPT LANGUAGE=JavaScript FOR=fromdays EVENT=onkeypress>
    /* FromDays onchange */
    if(event.keyCode<48 || event.keyCode>57)	return false;
    </SCRIPT>
    
    <SCRIPT LANGUAGE=JavaScript FOR=todays EVENT=onkeypress>
    /* todays onchange */
    if(event.keyCode<48 || event.keyCode>57)	return false;
    </SCRIPT>
    
    <SCRIPT LANGUAGE=JavaScript FOR=cancelpercentage EVENT=onkeypress>
    /* cancelpercentage onchange */
    if(event.keyCode<48 || event.keyCode>57)	return false;
    </SCRIPT>
    
    </head>
    <body>
    <%
    set conn=server.createobject("Adodb.Connection")
    conn.open "provider=sqloledb;server=10.16.120.247;database=ONLMGR_Temp;uid=icicidev;pwd=devuser123;"
    sql="select productcode,productname from omtbl_smproductmaster order by productcode"
    set rs=conn.execute(sql)
    
    
    %>
    <form name="cancellationrate" method="post" action="">
    <INPUT type=hidden value=HealthCancellationRate name=title>&nbsp; 
     <INPUT type="hidden"  id=Field_12 value=NewValue name=Field_12 customtype="HIDDEN" acl="" Label="TestField"> 
    <INPUT  type="hidden" id=Field_11 value=MyProduct name=Field_11 customtype="HIDDEN" acl="" Label="ProductCode">
    
    <TABLE cellSpacing=0 cellPadding=0 width="80%" align=center border=0>
    <TBODY>
    <TR>
    <TD class=header>Health</TD></TR></TBODY></TABLE>
    <TABLE class=tblbrd cellSpacing=0 cellPadding=0 width="90%" align=center border=0>
    <TBODY>
    <TR>
    <TD class=tdprop13><B>Cancellation Rate Master</B></TD>
    <TD class=tdprop13>| Enter all the details and press submit</TD></TR></TBODY></TABLE>
    <TABLE cellSpacing=0 cellPadding=0 width="90%" align=center border=0>
    <TBODY>
    <TR>
    <TD class=tdprop38 align=right>Fields marked by <FONT color=red size=3><B>*</B></FONT> are mandatory. </TD></TR></TBODY></ TABLE></TABLE>
    <TABLE cellSpacing=0 cellPadding=0 width="90%" align=center border=0>
    <TBODY>
    <TR>
    <TD class=tdborder2>
    <TABLE onreadystatechange=readystateinfo(this) cellSpacing=1 cellPadding=2 width="100%" align=center border=0>
    <TBODY>
    <TR>
    <TD class=tdprop25 width="35%">Product&nbsp;<FONT color=#ff0000>*</FONT></TD>
    <TD class=tdprop24 width="65%"><SELECT id=Field_4 name=Field_4 customtype="DROPDOWN" acl="" Label="product" AutoFill="" Validate=""><OPTION value=1 selected>--Select Product--</OPTION>
    <%
    if not rs.eof then 
    while not rs.eof 
    %>
    <option value="<%=rs("productcode")%>"><%=rs("productname")%></option>
    <%
    rs.movenext
    wend 
    rs.close
    set rs=nothing
    end if %>
    </SELECT></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
    <TABLE cellSpacing=0 cellPadding=0 width="90%" align=center border=0>
    <TBODY>
    <TR>
    <TD><FONT face=arial size=2><B>Cancellation Rate Details</B></FONT></TD></TR></TBODY></TABLE>
    <TABLE id=locationTbl1 style="DISPLAY: inline" cellSpacing=0 cellPadding=0 width="90%" align=center border=0>
    <TBODY>
    <TR>
    <TD class=tdborder2>
    <TABLE onreadystatechange=readystateinfo(this) cellSpacing=1 cellPadding=2 width="100%" border=0>
    <THEAD class=tdprop30>
    <TR>
    <TD width="30%">Cancellation Type&nbsp;<FONT color=#ff0000>*</FONT></TD>
    <TD width="25%">From Days&nbsp;<FONT color=#ff0000>*</FONT></TD>
    <TD width="25%">To Days&nbsp;<FONT color=#ff0000>*</FONT></TD>
    <TD width="20%">Cancellation Charges (%)&nbsp;<FONT color=#ff0000>*</FONT></TD>
    <TD width="10%">Add</TD></TR></THEAD>
    <TBODY class=tdprop12>
    <TR>
    <TD><SELECT class=tdprop24 name=cbotype><OPTION value="" selected>-- Select Type--</OPTION> <OPTION value=Applied>Applied</OPTION> <OPTION value=Misselling>Misselling</OPTION></SELECT></TD>
    <TD><INPUT class=fieldprop1 id=fromdays style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=4 name=fromdays></TD>
    <TD><INPUT class=fieldprop1 id=todays style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=4 name=todays></TD>
    <TD><INPUT class=fieldprop1 id=cancelpercentage style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=3 name=cancelpercentage></TD>
    <TD><INPUT class=button id=Field_5 onclick=javascript:check_add_canceltype() type=button maxLength=1024 value=Add customtype="BUTTON" acl="" Label="btnAddcanceltype" Validate=" "></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR><BR>
    <DIV id=divxmltbl1 style="display:none">
    <TABLE cellSpacing=0 cellPadding=0 width="90%" align=center border=0>
    <TBODY>
    <TR>
    <TD class=tdborder2>
    <TABLE id=TAB_xmlTbl1 onreadystatechange=readystateinfo(this) cellSpacing=1 cellPadding=2 width="100%" border=0 xmltable="xmlTbl1">
    <THEAD class=tdprop30>
    <TR>
    <TD>Cancellation Type</TD>
    <TD>From Days</TD>
    <TD>To Days</TD>
    <TD>Cancellation Charges (%)</TD>
    <TD></TD></TR></THEAD>
    <TBODY class=tdprop12>
    <TR>
    <TD><INPUT class=fieldprop1 id=Field_6 name=Field_6 customtype="READONLY" acl="" Label="cancellationtype" Validate=" "></TD>
    <TD><INPUT class=fieldprop1 id=Field_7 style="TEXT-ALIGN: right" name=Field_7 customtype="READONLY" acl="" Label="fromdays" Validate=" "></TD>
    <TD><INPUT class=fieldprop1 id=Field_8 style="TEXT-ALIGN: right" name=Field_8 customtype="READONLY" acl="" Label="todays" Validate=" "></TD>
    <TD><INPUT class=fieldprop1 id=Field_9 style="TEXT-ALIGN: right" name=Field_9 customtype="READONLY" acl="" Label="cancellationpercentage" Validate=" "></TD>
    <TD><INPUT class=fieldprop1 id=Field_10 style="WIDTH: 1px" size=1 name=Field_10 customtype="HIDDEN" acl="" Label="productcode" Validate=" "></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV>
    <TABLE cellSpacing=0 cellPadding=0 align=center border=0>
    <TBODY>
    <TR>
    <TD class=tdprop37 id=TDSubmit>&nbsp; <INPUT class=button id=button1 onclick=showButton() type=button value=Submit name=button1>&nbsp; <INPUT class=button onclick=window.history.back(); type=button value=Cancel name=cancel> </TD></TR></TBODY></TABLE>
    
    </form>
    </body>
    </html>
    Nothing is Impossible bcoz IMPOSSIBLE itself says..
    I M POSSIBLE........................
    Be cool !!!!!!!!
  2. #2
  3. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2925
    hey Guddu, I'm not familiar with this kind of AJAX code..
    can you tell what code is adding the rows?
  4. #3
  5. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Jun 2004
    Posts
    1,657
    Rep Power
    241
    Not too clear what you want to achieve. can you explain in detail
  6. #4
  7. Contributing User
    ASP High Scholar (3500 - 3999 posts)

    Join Date
    Jul 2005
    Location
    Oxford UK
    Posts
    3,897
    Rep Power
    992
    hey if each time user click on add button than i want to add a row with text boxes....
  8. #5
  9. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Jun 2004
    Posts
    1,657
    Rep Power
    241
    you can use the following code as an example. The following is a working script.

    Code:
    <html>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 2</title>
    </head>
    <SCRIPT LANGUAGE=JavaScript >
    
    function AddItem(id){
    	var table,tbodies,row,td1,td2,td3
    	table = document.getElementById('locationTbl')
        tbodies = table.getElementsByTagName("TBODY");
        row = document.getElementById('row' + id + 'Clone').cloneNode(true)
        row.id = "row" + id
        tbodies[0].appendChild(row);
        return row
    }
    </script>
    <body>
    <TABLE id="locationTbl" cellSpacing=1 cellPadding=2 width="100%" border=0>
    <THEAD class=tdprop30>
    <TR>
    <TD width="30%">Cancellation Type*<FONT color=#ff0000>*</FONT></TD>
    <TD width="25%">From Days*<FONT color=#ff0000>*</FONT></TD>
    <TD width="25%">To Days*<FONT color=#ff0000>*</FONT></TD>
    <TD width="20%">Cancellation Charges (%)*<FONT color=#ff0000>*</FONT></TD>
    <TD width="10%">Add</TD></TR></THEAD>
    <TBODY class=tdprop12>
    <TR>
    <TD><SELECT class=tdprop24 name=cbotype><OPTION value="" selected>-- Select Type--</OPTION> <OPTION value=Applied>Applied</OPTION> <OPTION value=Misselling>Misselling</OPTION></SELECT></TD>
    <TD><INPUT class=fieldprop1 id=fromdays style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=4 name=fromdays></TD>
    <TD><INPUT class=fieldprop1 id=todays style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=4 name=todays></TD>
    <TD><INPUT class=fieldprop1 id=cancelpercentage style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=3 name=cancelpercentage></TD>
    <TD><INPUT class=button id=Field_5 onclick=javascript:AddItem('1') type=button maxLength=1024 value=Add customtype="BUTTON" acl="" Label="btnAddcanceltype" Validate=" "></TD></TR>
    </TBODY>
    </TABLE>
    
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <div style="visibility:hidden">
    <TABLE cellSpacing=1 cellPadding=2 width="100%" border=0 id="table1">
    <TR  id="Row1Clone" >
    <TD><SELECT class=tdprop24 name=cbotype0><OPTION value="" selected>-- Select Type--</OPTION> <OPTION value=Applied>Applied</OPTION> <OPTION value=Misselling>Misselling</OPTION></SELECT></TD>
    <TD>
    <INPUT class=fieldprop1 id=fromdays0 style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=4 name=fromdays0></TD>
    <TD>
    <INPUT class=fieldprop1 id=todays0 style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=4 name=todays0></TD>
    <TD>
    <INPUT class=fieldprop1 id=cancelpercentage0 style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=3 name=cancelpercentage0></TD>
    <TD>&nbsp;</TD></TR>
    </TABLE>
    </div>
    </body>
    
    </html>
  10. #6
  11. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2925
    Guddu, I fear the code you posted is not relevant at all..
    you better start from the beginning, the code Barney gave
    looks good.
  12. #7
  13. Contributing User
    ASP High Scholar (3500 - 3999 posts)

    Join Date
    Jul 2005
    Location
    Oxford UK
    Posts
    3,897
    Rep Power
    992
    hey barney this is okay but what i want to do is.when user click on add than enterd data is added to text boxes..i mean to say the added value will display here
    Code:
    <div style="visibility:hidden">
    <TABLE cellSpacing=1 cellPadding=2 width="100%" border=0 id="table1">
    <TR  id="Row1Clone" >
    <TD><SELECT class=tdprop24 name=cbotype0><OPTION value="" selected>-- Select Type--</OPTION> <OPTION value=Applied>Applied</OPTION> <OPTION value=Misselling>Misselling</OPTION></SELECT></TD>
    <TD>
    <INPUT class=fieldprop1 id=fromdays0 style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=4 name=fromdays0></TD>
    <TD>
    <INPUT class=fieldprop1 id=todays0 style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=4 name=todays0></TD>
    <TD>
    <INPUT class=fieldprop1 id=cancelpercentage0 style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=3 name=cancelpercentage0></TD>
    <TD>*</TD></TR>
    </TABLE>
    </div>
  14. #8
  15. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Jun 2004
    Posts
    1,657
    Rep Power
    241
    This can copy all information typed in the text boxes. For the dropdown, it cannot be directly copied with the selected value, so I have changed that to a text field in the newly added row.
    I hope this will help you. The validations you can add on to this code.
    Code:
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 2</title>
    </head>
    <SCRIPT LANGUAGE=JavaScript >
    
    function AddItem(id){
    	document.getElementById('F1').value = document.getElementById('cbotype')[document.getElementById('cbotype').selectedIndex].text
    	document.getElementById('F2').value = document.getElementById('fromdays').value 
    	document.getElementById('F3').value = document.getElementById('todays').value 
    	document.getElementById('F4').value = document.getElementById('cancelpercentage').value 
    
    
    	var table,tbodies,row,td1,td2,td3
    	table = document.getElementById('locationTbl')
        tbodies = table.getElementsByTagName("TBODY");
        row = document.getElementById('row' + id + 'Clone').cloneNode(true)
        row.id = "row" + id
        tbodies[0].appendChild(row);
        return row
    }
    </script>
    <body>
    <TABLE  cellSpacing=1 cellPadding=2 width="100%" border=0>
    <THEAD class=tdprop30>
    <TR>
    <TD width="17%">Cancellation Type*<FONT color=#ff0000>*</FONT></TD>
    <TD width="34%">From Days*<FONT color=#ff0000>*</FONT></TD>
    <TD width="25%">To Days*<FONT color=#ff0000>*</FONT></TD>
    <TD width="20%">Cancellation Charges (%)*<FONT color=#ff0000>*</FONT></TD>
    <TD width="10%"></TD></TR></THEAD>
    <TBODY class=tdprop12>
    <TR>
    <TD><SELECT class=tdprop24 name=cbotype id=cbotype><OPTION value="" selected>-- Select Type--</OPTION> <OPTION value=Applied>Applied</OPTION> <OPTION value=Misselling>Misselling</OPTION></SELECT>&nbsp;
    </TD>
    <TD><INPUT class=fieldprop1 id=fromdays style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=4 name=fromdays></TD>
    <TD><INPUT class=fieldprop1 id=todays style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=4 name=todays></TD>
    <TD><INPUT class=fieldprop1 id=cancelpercentage style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=3 name=cancelpercentage></TD>
    <TD>
    <INPUT class=button id=Field_5 onclick=javascript:AddItem('1') type=button maxLength=1024 value="Add" customtype="BUTTON" acl="" Label="btnAddcanceltype" Validate=" "></TD></TR>
    </TBODY>
    </TABLE>
    
    <Div style="visibility:hidden">
    <TABLE  cellSpacing=1 cellPadding=2 width="100%" border=0 id="table1">
    <TR id="Row1Clone" >
    <TD width="201">&nbsp;<INPUT class=fieldprop1 style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" id=F1 name=F1 id=SelText size="20">
    </TD>
    <TD>
    <INPUT class=fieldprop1 style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=4 name=F2  id=F2 size="20"></TD>
    <TD>
    <INPUT class=fieldprop1  style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=4 name=F3  id=F3 size="20"></TD>
    <TD>
    <INPUT class=fieldprop1  style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=3 name=F4  id=F4 size="20"></TD>
    </TR>
    </TABLE>
    </div>
    
    <br>
    &nbsp;</p>
    </br>
    <div style="visibility:visible">
    <TABLE id="locationTbl" cellSpacing=1 cellPadding=2 width="100%" border=0 id="table1">
    
    </TABLE>
    </div>
    </body>
    
    </html>
  16. #9
  17. Contributing User
    ASP High Scholar (3500 - 3999 posts)

    Join Date
    Jul 2005
    Location
    Oxford UK
    Posts
    3,897
    Rep Power
    992
    okay barney .now i want to add more fields to it ..actually cancelpercentage
    has five text field like cancelpercentage(1 year),cancelpercentage(2 year),
    and upto cancelpercentage(5 years),..and user will enter values here..and after clicking on add button it will add this values into below added table .
    Code:
    <TABLE  cellSpacing=1 cellPadding=2 width="100%" border=1>
    <THEAD class=tdprop30>
    <TR>
    <TD width="17%">Cancellation Type<FONT color=#ff0000>*</FONT></TD>
    <TD width="34%">From Days<FONT color=#ff0000>*</FONT></TD>
    <TD width="25%">To Days<FONT color=#ff0000>*</FONT></TD>
    <TD width="20%">Cancellation Charges (%)<FONT color=#ff0000>*</FONT></TD>
    <TD width="10%"></TD></TR></THEAD>
    <TBODY class=tdprop12>
    <TR>
    <TD><SELECT class=tdprop24 name=cbotype id=cbotype><OPTION value="" selected>-- Select Type--</OPTION> <OPTION value=Applied>Applied</OPTION> <OPTION value=Misselling>Misselling</OPTION></SELECT>
    </TD>
    <TD><INPUT class=fieldprop1 id=fromdays style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=4 name=fromdays></TD>
    <TD><INPUT class=fieldprop1 id=todays style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=4 name=todays></TD>
    <TD><INPUT class=fieldprop1 id=cancelpercentage style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=3 name=cancelpercentage></TD>
    <TD>
    <INPUT class=button id=Field_5 onclick=javascript:check_add_canceltype(); type=button maxLength=1024 value="Add" customtype="BUTTON" acl="" Label="btnAddcanceltype" Validate=" "></TD></TR>
    </TBODY>
    </TABLE>
  18. #10
  19. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Jun 2004
    Posts
    1,657
    Rep Power
    241
    You just follow my previous post code and modify according to your need.

    I cannot give you the exact script what you need, instead you have to make use of the given example to fit your requirement.
  20. #11
  21. Contributing User
    ASP High Scholar (3500 - 3999 posts)

    Join Date
    Jul 2005
    Location
    Oxford UK
    Posts
    3,897
    Rep Power
    992
    yeah i m doing that...okay now i want some validation ...if user select cancellation type applied and from days=1,and todays=365..and click on add button than this values will added to below text boxes....and if user try to add this same value again than i want to show them alert ..this is already added...u can't add this.
  22. #12
  23. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Jun 2004
    Posts
    1,657
    Rep Power
    241
    This is not the exact validation what you want but follow this one to do your validation.

    You follow the similar code for all other field validations.

    Code:
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 2</title>
    </head>
    <SCRIPT LANGUAGE=JavaScript >
    
    function AddItem(id){
    if (document.frm.F1)
    {
    	for (i=0;i<document.frm.F1.length;i++)
    	{
    		if (document.getElementById('cbotype')[document.getElementById('cbotype').selectedIndex].text == document.frm.F1[i].value)
    		{
    			alert ('value already added')
    			return
    		}
    	}	
    }
    	document.getElementById('F1').value = document.getElementById('cbotype')[document.getElementById('cbotype').selectedIndex].text
    	document.getElementById('F2').value = document.getElementById('fromdays').value 
    	document.getElementById('F3').value = document.getElementById('todays').value 
    	document.getElementById('F4').value = document.getElementById('cancelpercentage').value 
    
    
    	var table,tbodies,row,td1,td2,td3
    	table = document.getElementById('locationTbl')
        tbodies = table.getElementsByTagName("TBODY");
        row = document.getElementById('row' + id + 'Clone').cloneNode(true)
        row.id = "row" + id
        tbodies[0].appendChild(row);
        return row
    }
    </script>
    <body>
    <form name=frm id=frm>
    <TABLE  cellSpacing=1 cellPadding=2 width="100%" border=0>
    <THEAD class=tdprop30>
    <TR>
    <TD width="17%">Cancellation Type*<FONT color=#ff0000>*</FONT></TD>
    <TD width="34%">From Days*<FONT color=#ff0000>*</FONT></TD>
    <TD width="25%">To Days*<FONT color=#ff0000>*</FONT></TD>
    <TD width="20%">Cancellation Charges (%)*<FONT color=#ff0000>*</FONT></TD>
    <TD width="10%"></TD></TR></THEAD>
    <TBODY class=tdprop12>
    <TR>
    <TD><SELECT class=tdprop24 name=cbotype id=cbotype><OPTION value="" selected>-- Select Type--</OPTION> <OPTION value=Applied>Applied</OPTION> <OPTION value=Misselling>Misselling</OPTION></SELECT>*
    </TD>
    <TD><INPUT class=fieldprop1 id=fromdays style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=4 name=fromdays></TD>
    <TD><INPUT class=fieldprop1 id=todays style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=4 name=todays></TD>
    <TD><INPUT class=fieldprop1 id=cancelpercentage style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=3 name=cancelpercentage></TD>
    <TD>
    <INPUT class=button id=Field_5 onclick=javascript:AddItem('1') type=button maxLength=1024 value="Add" customtype="BUTTON" acl="" Label="btnAddcanceltype" Validate=" "></TD></TR>
    </TBODY>
    </TABLE>
    
    <Div style="visibility:hidden">
    <TABLE  cellSpacing=1 cellPadding=2 width="100%" border=0 id="table1">
    <TR id="Row1Clone" >
    <TD width="201"><INPUT class=fieldprop1 style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" id=F1 name=F1 size="20">
    </TD>
    <TD>
    <INPUT class=fieldprop1 style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=4 name=F2  id=F2 size="20"></TD>
    <TD>
    <INPUT class=fieldprop1  style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=4 name=F3  id=F3 size="20"></TD>
    <TD>
    <INPUT class=fieldprop1  style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=3 name=F4  id=F4 size="20"></TD>
    </TR>
    </TABLE>
    </div>
    
    <br>
    *</p>
    </br>
    <div style="visibility:visible">
    <TABLE id="locationTbl" cellSpacing=1 cellPadding=2 width="100%" border=0 id="table1">
    
    </TABLE>
    </div>
    </form>
    </body>
    
    </html>
  24. #13
  25. Contributing User
    ASP High Scholar (3500 - 3999 posts)

    Join Date
    Jul 2005
    Location
    Oxford UK
    Posts
    3,897
    Rep Power
    992
    okay i go through it...barney i want to add one more row.. with this
    like this
    Code:
    <Div style="visibility:hidden">
    <TABLE  cellSpacing=1 cellPadding=2 width="100%" border=1 id="table1">
    
    <TR >
    <TD width="17%">Cancellation Type<FONT color=#ff0000>*</FONT></TD>
    <TD width="34%">From Days<FONT color=#ff0000>*</FONT></TD>
    <TD width="25%">To Days<FONT color=#ff0000>*</FONT></TD>
    <TD width="20%">Cancellation Charges(1 year) (%)<FONT color=#ff0000>*</FONT></TD>
    <TD width="20%">Cancellation Charges(2 years) (%)<FONT color=#ff0000>*</FONT></TD>
    <TD width="20%">Cancellation Charges(3 years) (%)<FONT color=#ff0000>*</FONT></TD>
    <TD width="20%">Cancellation Charges(4 years) (%)<FONT color=#ff0000>*</FONT></TD>
    <TD width="20%">Cancellation Charges(5 years) (%)<FONT color=#ff0000>*</FONT></TD>
    <TD width="10%"></TD></TR>
    <TR id="Row1Clone" >
    <TD width="201"><INPUT class=fieldprop1 style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=4 name=F1  id=F1 size="20">
    </TD>
    <TD>
    <INPUT class=fieldprop1 style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=4 name=F2  id=F2 size="20"></TD>
    <TD>
    <INPUT class=fieldprop1  style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=4 name=F3  id=F3 size="20"></TD>
    <TD>
    <INPUT class=fieldprop1  style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=3 name=F4  id=F4 size="20"></TD>
    <TD>
    <INPUT class=fieldprop1  style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=3 name=F5  id=F5 size="20"></TD>
    <TD>
    <INPUT class=fieldprop1  style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=3 name=F6  id=F6 size="20"></TD>
    <TD>
    <INPUT class=fieldprop1  style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=3 name=F7  id=F7 size="20"></TD>
    <TD>
    <INPUT class=fieldprop1  style="WIDTH: 109px; HEIGHT: 20px; TEXT-ALIGN: right" maxLength=3 name=F8  id=F8 size="20"></TD>
    
    </TR>
    </TABLE>
    </div>
  26. #14
  27. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Jun 2004
    Posts
    1,657
    Rep Power
    241
    Go through the code which I have provided. It will be very easy for you to modify accoding to your need. Now I dont have time to change it according to your need. If you still cant modify the code I will do it when I find time.
  28. #15
  29. Contributing User
    ASP High Scholar (3500 - 3999 posts)

    Join Date
    Jul 2005
    Location
    Oxford UK
    Posts
    3,897
    Rep Power
    992
    hey barney even i don't understand your this code than how i can modify it
    Code:
    var table,tbodies,row,td1,td2,td3
    	table = document.getElementById('locationTbl')
        tbodies = table.getElementsByTagName("TBODY");
    	//Rowfixed=document.getElementById('Rowfixed').cloneNode(true)
        row = document.getElementById('row' + id + 'Clone').cloneNode(true)
        row.id = "row" + id
        tbodies[0].appendChild(row);
        return row
Page 1 of 3 123 Last
  • Jump to page:

Similar Threads

  1. Onclick event working in IE, not in Mozilla
    By skinnerback in forum HTML, JavaScript And CSS Help
    Replies: 3
    Last Post: September 14th, 2006, 06:53 AM
  2. Calling VBScript function via onclick event
    By bluh_11 in forum ASP Development
    Replies: 5
    Last Post: August 16th, 2006, 06:18 PM
  3. Replies: 0
    Last Post: February 6th, 2004, 12:03 PM
  4. Passed values Using Onclick event of Input type=button
    By Steve Schofield in forum .NET Development
    Replies: 0
    Last Post: December 18th, 2000, 10:54 PM
  5. Trouble using onclick event with
    By Steve Schofield in forum ASP Development
    Replies: 1
    Last Post: July 11th, 2000, 03:51 AM

IMN logo majestic logo threadwatch logo seochat tools logo