...

View Full Version : "Help" Save values into database from dynamically created text field



sabiha
07-18-2009, 09:47 AM
hello,
i m new to java script.i have created text fields dynamically by clicking a button now problem is that i want to save the value of these text field into database. i m using java script with PHP's framework codeigniter. the code is as follows

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CrossBiz Internal</title>
<link rel="stylesheet" href="<?= base_url() ?>css/personal.css" type="text/css" />
<link href="<?= base_url()?>css/calendar.css" rel="stylesheet" type="text/css" />
<link href="<?= base_url()?>css/personal.css" rel="stylesheet" type="text/css" />



<script language="javascript" type="text/javascript">
var boxctr = 2105;
function addnew_edu()
{

document.getElementById("mydiv1").innerHTML +='<BR /><input name="edu_title" type="text" size="15" value="<?php echo set_value('edu_title')?>"/>&nbsp;<input name="edu_year" type="text" size="15" value="<?php echo set_value('edu_year')?>"/>&nbsp;<input name="edu_institute" type="text" size="15" value="<?php echo set_value('edu_institute')?>"/>&nbsp;<input name="edu_grade" type="text" size="15" value="<?php echo set_value('edu_grade')?>" />&nbsp;<input style="color:#DC2C12" type="button" name="add_edu" value="+" title="Add new row" onclick="addnew_edu();"/>&nbsp;<input style="color:#DC2C12" type="button" name="del_edu" value="X" title="Delete row";"/>';

}

function addnew_exp()
{
//boxctr++;
//var temp = boxctr + 1;
//var next_index = boxctr + 2;
//var next2_index = boxctr +3;
document.getElementById("mydiv2").innerHTML +='<BR /><input name="exp_title" type="text" size="11" value="<?php echo set_value('exp_title')?>"/>&nbsp;<input name="exp_company" type="text" size="11" value="<?php echo set_value('exp_company')?>"/>&nbsp;<input name="exp_designation" type="text" size="11" value="<?php echo set_value('exp_designation')?>"/>&nbsp;<input name="exp_from" type="text" size="11" value="<?php echo set_value('exp_from')?>" />&nbsp;<input name="exp_to" type="text" size="11" value="<?php echo set_value('exp_to')?>" />&nbsp;<input style="color:#DC2C12" type="button" name="add_exp" value="+" title="Add new row" onclick="addnew_exp();"/>&nbsp;<input style="color:#DC2C12" type="button" name="del_exp" value="X" title="Delete row";"/>';
//boxctr++;
//boxctr++;
}

</script>
</head>
<body>
<table width="100%" border="0" align="center" id="mastertable">
<tr>
<td nowrap="nowrap" id="logo"><div align="left">CrossBiz</div></td>
<td nowrap="nowrap" class="user"><div align="right"><?= @$_SESSION['login_name']?></div></td>
</tr>

<tr>
<td colspan="2" nowrap="nowrap" class="menutop" width="92%">
<?= $this->load->view('menu') ?>
</td>
</tr>
<link href="../../../css/personal.css" rel="stylesheet" type="text/css" />
<tr>
<td colspan="2" id="mainbody" valign="top">
<table align="left">
<tr>
<th class="breadcrumb"><a href="<?= base_url()?>index.php/user/personal"/>Personal</a></th>
<th style="color:#000000">--->></th>
<th class="breadcrumb"><a href="<?= base_url()?>index.php/user/employees"/>Employees</a></th>
<th style="color:#000000">--->></th>
<th class="breadcrumb"><a href="#"/>Add New</a></th>
</tr>
</table>
<p>
<br/>
</p>
<!-- main body starts here -->
<?=form_open('user/empdata_form')?>
<table width="550" cellspacing="0" cellpadding="0" align="center" class="tablelogin" bgcolor="#F2F2F2">

<tr>
<td align="left" class="heading">Education:</td>
</tr>
<tr>
<td>
<table align="center" cellpadding="0" cellspacing="0" class="border_tl">
<tr>
<td><input name="emp_id" type="hidden" value="<?= @$td->emp_id?>" /></td>
</tr>
<tr>
<th class="border_rb" align="left" width="530">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Title &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Year &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Institute &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Grade&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </th>
</tr>
<tr>
<td align="center" width="530">
<div id="mydiv1">
<input name="edu_title" type="text" size="15" value="<?php echo set_value('edu_title')?>"/>
<input name="edu_year" type="text" size="15" value="<?php echo set_value('edu_year')?>"/>
<input name="edu_institute" type="text" size="15" value="<?php echo set_value('edu_institute')?>"/>
<input name="edu_grade" type="text" size="15" value="<?php echo set_value('edu_grade')?>" />
<input style="color:#DC2C12" type="button" name="add_edu" value="+" title="Add new row" onClick="addnew_edu();"/>
<input style="color:#DC2C12" type="button" name="delete_edu" value="X" title="Delete"/>
</div>
</td>
</tr>
</table>
</td>
</tr>

<tr align="center">
<td>
<input type="submit" name="submit" value="Submit" class="btn"/>
<input type="submit" name="cancel" value="Cancel" class="btn"/>
</td>
</tr>

</table>
<?=form_close()?>
<br/>
<!-- main body starts here -->
</td>
</tr>
</table>
</body>
</html>

A1ien51
07-18-2009, 01:38 PM
Use code tags!

Isn;t this a PHP problem and not a JavaScript one. Are you reading the values in the php page you are submitting it to with _POST?

Eric



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum