TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-10-2007, 10:30 AM   #1 (permalink)
The Contributor
Upcoming Programmer 
 
meshi's Avatar
 
Join Date: Oct 2007
Posts: 44
Thanks: 0
meshi is on a distinguished road
Default how to put span in Js

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");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";
	}
}
}
the output of this is
con pos tel email
meshi janitor 0555 dfdsf@y.com

if i put a span tags in the email side how would i do that in scripts
hope u could help me
PS
my span has also a class="notaction"
how would i add it to my code
meshi is offline  
Reply With Quote
Old 10-10-2007, 03:21 PM   #2 (permalink)
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default

I'm sorry, I dont quite understand you, could you be more specific?
Karl is offline  
Reply With Quote
Old 10-10-2007, 03:39 PM   #3 (permalink)
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
Old 10-10-2007, 04:02 PM   #4 (permalink)
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default

Ah, I see. Try this:

Add the following code to your addRow function:

Code:
var pAnchor = document.createElement('a');
pAnchor.href = 'mailto:' + email;

var pSpan = document.createElement('span');
pSpan.className = 'notaction';
pSpan.appendChild(pAnchor);
Then replace this code:

Code:
document.createElement("SPAN");td4.appendChild(document.createTextNode(email));
with:

Code:
td4.appendChild(pSpan);
Karl is offline  
Reply With Quote
Old 10-11-2007, 12:21 PM   #5 (permalink)
The Contributor
Upcoming Programmer 
 
meshi's Avatar
 
Join Date: Oct 2007
Posts: 44
Thanks: 0
meshi is on a distinguished road
Default

i did ur advice but it has no display on email field..i change my JS.and what i did is this one
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");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++)
	{
		if (((i+1)%4)==0)
			col[i].className = "table-list-entry1 notaction";
		else       
			col[i].className = "table-list-entry1";       
	}
}
}
my problem now is how to put mailto in the email field?forget the span thing i only want to put mailto..how would i do that?
meshi is offline  
Reply With Quote
Old 10-11-2007, 12:31 PM   #6 (permalink)
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default

Hmm, the last bit of code I gave you should have put the mailto: link in with the anchor. Did you try it?
Karl is offline  
Reply With Quote
Old 10-11-2007, 12:46 PM   #7 (permalink)
The Contributor
Upcoming Programmer 
 
meshi's Avatar
 
Join Date: Oct 2007
Posts: 44
Thanks: 0
meshi is on a distinguished road
Default

yeah i did but there is no display in the email field
meshi is offline  
Reply With Quote
Old 10-11-2007, 01:00 PM   #8 (permalink)
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default

Ah I forgot something in the last bit of code I posted. If you ammend this code:

Code:
var pAnchor = document.createElement('a');
pAnchor.href = 'mailto:' + email;

var pSpan = document.createElement('span');
pSpan.className = 'notaction';
pSpan.appendChild(pAnchor);
by adding the following line:

Code:
pAnchor.innerHTML = email;
So that it looks like:

Code:
var pAnchor = document.createElement('a');
pAnchor.href = 'mailto:' + email;
pAnchor.innerHTML = email;

var pSpan = document.createElement('span');
pSpan.className = 'notaction';
pSpan.appendChild(pAnchor);
If you try to run that again you should see the valid mailto link with the anchor text set to the value of email.
Karl is offline  
Reply With Quote
Old 10-11-2007, 01:21 PM   #9 (permalink)
The Contributor
Upcoming Programmer 
 
meshi's Avatar
 
Join Date: Oct 2007
Posts: 44
Thanks: 0
meshi is on a distinguished road
Default

its ok now....thanks karl...ur the best...its been a long time since i start solving this problem...thank u thank u thank u
meshi is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 12:25 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design