View Single Post
Old 10-10-2007, 03:39 PM   #3 (permalink)
meshi
The Contributor
Upcoming Programmer 
 
meshi's Avatar
 
Join Date: Oct 2007
Posts: 44
Thanks: 0
meshi is on a distinguished road
Default

this code is a pop up page that inputs all the needed datas
PHP Code:
$text_array = array(
          
'Firstname' => array ( 
                    
'name'=> 'firstname'
                    
'text'=> 'Firstname',
                    
'type'=> 'text',
                    
'class'=>'inputbox',
                    
'value'=>"$row[confirstname]"
                 
),
                     
'Lastname'=> array ( 
                    
'name'=> 'lastname'
                    
'text'=> 'Lastname'
                    
'type'=> 'text',
                    
'class'=>'inputbox',
                    
'value'=>"$row[conlastname]"
                 
),
                  
'Salutation' => array ( 
                    
'name'=> 'salutation'
                    
'text'=> 'Salutation'
                    
'type'=> 'text',
                    
'class'=>'inputbox'
                 
),
                 
'Position' => array ( 
                    
'name'=> 'position'
                    
'text'=> 'Position'
                    
'type'=> 'text',
                    
'class'=>'inputbox',
                    
'value'=>"$row[position]"
                 
), 
                 
'Decision Maker' => array ( 
                    
'name'=> 'dm'
                    
'text'=> 'Decision Maker',
                    
'type'=> 'checkbox',
                    
'checkbox'=>'true',
                    
'value'=> "$row[dm]"    
                 
),
                 
'Direc Dial' => array ( 
                    
'name'=> 'ddial'
                    
'text'=> 'Telephone Number'
                    
'type'=> 'text',
                    
'class'=>'inputbox',
                    
'value'=>"$row[direct_dial]"
                 
),
                 
'Email Address' => array ( 
                    
'name'=> 'email'
                    
'text'=> 'Email Address'
                    
'type'=> 'text',
                    
'class'=>'inputbox',
                    
'value'=>"$row[emailad]"
                 
),
);
if(isset(
$_POST['save']))
    {
    
$query="insert into rec_contacts(employer_id,confirstname,conlastname,salutation,position,dm,direct_dial,emailad,con_coment)VALUES('$empid','$_POST[firstname]','$_POST[lastname]','$_POST[salutation]','$_POST[position]','$value','$_POST[ddial]','$_POST[email]','$_POST[con_coment]')";
    
$result=mysql_query($query);
    
$query    =    "select * from rec_contacts where employer_id='$empid'";
     echo 
"<script language='Javascript'>
                    alert('Data successfully saved');
                          window.opener.addRow('
$fname','$_POST[position]','$_POST[ddial]','$_POST[email]');
                          window.opener.applystyle('contact');                    
                    window.close();
                   </script>"
;
    }    

this page will display wat u just inputed

Code:
function addRow(con,pos,tel,email)
{
	var tbody=document.getElementById('contact').getElementsByTagName("TBODY")[0];
	var row = document.createElement("TR");
	var td1 = document.createElement("TD");td1.appendChild(document.createTextNode(con));
	var td2 = document.createElement("TD");td2.appendChild(document.createTextNode(pos));
	var td3 = document.createElement("TD");td3.appendChild (document.createTextNode(tel));
	var td4 = document.createElement("TD");document.createElement("SPAN");td4.appendChild(document.createTextNode(email));
	row.appendChild(td1);row.appendChild(td2);row.appendChild(td3);row.appendChild(td4);tbody.appendChild(row);
}
function applystyle(id)
{
	if(document.getElementsByTagName)
{
	var table = document.getElementById(id);
	var col = table.getElementsByTagName("td");
	for(i = 4; i < col.length; i++)
	{
		col[i].className = "table-list-entry1";
	}


}
}
PHP Code:
$contact_array=array('Name','Position','Telephone No','Email');
    
    echo 
'<tr>';
                
contactlist($contact_array);              
    echo 
'</tr>';
    while(
$row=mysql_fetch_array($result))
    {
echo 
'<tr>
          <td class="table-list-entry1"><a href="'
; echo $_SERVER["PHP_SELF"]; echo '?click=addcontacts.php&menu=1&conid='.$row[contact_id].'">'.$row[confirstname].' '.$row[conlastname].'</a></td>
          <td class="table-list-entry1">'
.$row[position].'</td>
          <td class="table-list-entry1">'
.$row[direct_dial].'</td>
          <td class="table-list-entry1"><span class="notaction"><a href=mailto:'
.$row[emailad].'>'.$row[emailad].'</a></span></td></tr>';
        }
        echo 
'<tbody>';
        }
        else 
        {
        echo 
'<tr><td>No Contacts</td></tr>';
        echo 
'</tbody>';    
        } 
the flow of this code is when i click the add contact the popup page apear and u will input the needed data after that u will click the save button and the inputed data will display automatically to the first page.my problem is i dont know how to put the mailto and span on my script to make it similar to other data that coming from database or old data displayed b4 u add the new one...in the email field


PS
see where tbody is..that will display the new inputed data
meshi is offline  
Reply With Quote