submit form in JavaScript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aini hazes
    New Member
    • Mar 2012
    • 1

    submit form in JavaScript

    hi someone please help me. i have problem to submit the form that required to pass the parameter. the parameter is form the split data in the next page. Th coding is like below :

    Code:
    output = "<table border='0' width='100%' cellpadding='0' cellspacing='0' style='padding:5px 5px 5px 5px;font-family:arial;font-size:12px;text-align:center;'>\
    						<tr>\
    							<th width='5%'>#</th>\
    							<th width='15%'>Name</th>\
    							<th width='15%'>Leave Type</th>\
    							<th width='6%'>Current Balance</th>\
    							<th width='6%'>Pending Leave</th>\
    							<th width='6%'>Bal. Leave Can Apply</th>\
    							<th width='6%'>Bal. After Force Leave</th>\
    							<th width='15%'>Action</th>\
    						</tr>\
    			";
    			
    			for(i=0;i<row.length-1;i++)
    			{
    				col = row[i].split("<->");
    					
    				var staffName = col[0],leave_type=col[1],current_balance=col[2],pending_leave=col[3],balance_apply=col[4], balance_after_force=col[5], actionLeave=col[6];
    				
    				output += "<tr>\
    							<td>"+(i+1)+"</td>\
    							<td>"+staffName+"</td>\
    							<td>"+leave_type+"</td>\
    							<td>"+current_balance+"</td>\
    							<td>"+pending_leave+"</td>\
    							<td>"+balance_apply+"</td>\
    							<td>"+balance_after_force+"</td>\
    							<td>"+actionLeave+"</td>\
    							<!--td id='testing'><input type='text' value='"+staffName+"' id='staffname'></td-->\
    						</tr>\
    						";	
    			}
    			output += "</table><br><app_button onclick='submitForce("+staffName+")'>Submit</app_button>";							
     			$("#leave_record").html(output);
    		}
    	});
    
    }
    
    function submitForce(staffName)
    {
    	alert("masuk");
    }
    Last edited by Dormilich; Mar 13 '12, 09:30 PM. Reason: Please use [CODE] [/CODE] tags when posting code.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I don’t see where <-> should split a row. besides that, if you pass a string parameter, you would have to pass the quotes separately (that’s why inline JavaScript is so disadvantageous ).

    Comment

    Working...