Not Loading Function Into Div


Posted on 16th Feb 2014 07:03 pm by admin

I'm not sure whether to put this under the php forum or ajax forum but because I tink it's more of an issue wit the php code itself I decided to put it here. I came across this file from a friend that said this file will work for me. Okay now basically I have the list of characters and when someone clicks on Add New it will load the addcharacter function. That's what I want it to do. However with all of this it will not load the function. Am I missing something somewhere?

Code: var loadedobjects=""
var rootdomain="http://"+window.location.hostname

function ajaxpage(url, containerid)
{
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject)
{
// if IE
try
{
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e)
{
try
{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e)
{
}
}
}
else
{
return false
}

page_request.onreadystatechange=function()
{
loadpage(page_request, containerid)
}

page_request.open('GET', url, true)
page_request.send(null)
}

function loadpage(page_request, containerid)
{
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}

function loadobjs()
{
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++)
{
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1)
{
//Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1)
{
//If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1)
{
//If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!="")
{
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}
Code: <!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" xml:lang="en" lang="en">

<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="author" content="" />

<title>Untitled 1</title>
</head>

<body>

<?php {
print '<h1 class=backstage>Character Management</h1><br />';
print "<h2 class=backstage>Characters :: <a href="#" onclick="ajaxpage('addcharacter', 'content'); return false;">Add New</a></h2><br />";
$query = "SELECT
bio.charactername,
bio.style_id,
style.id,
style.name
FROM
efed_bio as bio
INNER JOIN
efed_list_styles as style
ON
style.id = bio.style_id";
$result = mysql_query ( $query ); // Run The Query
$rows = mysql_num_rows($result);
if ($rows > 0)
{

print '<table width="100%" class="table1">';
print '<tr class="rowheading">';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>Character Name</td>';
print '<td align=center width=100>Poser Name</td>';
print '<td align=center width=60>Style</td>';
print '<td align=center width=60>Alignment</td>';
print '<td align=center width=60>Status</td>';
print '</tr>';
// Fetch and print all records.
$i = 0;
$current_row = 0;
while ( $row = mysql_fetch_array ( $result, MYSQL_ASSOC ) ) {
$sClass = 'row2';
if ($i ++ & 1) {
$sClass = 'row1';
}
printf ( "<tr class="%s">", $sClass );
print "<td valign="top" align=center width=35><a href="#" onclick="ajaxpage('editcharacter', 'content'); return false;">Edit</a></td>";
print "<td valign="top" align=center width=25><a href="#" onclick="ajaxpage('bio', 'content'); return false;">Bio</a></td>";
printf ( "<td valign="top">%s</td>", $row ['charactername'] );
printf ( "<td align="center" valign="top">%s</td>", $row ['posername'] );
printf ( "<td align="center" valign="top">%s</td>", $row ['style_id'] );
printf ( "<td align="center" valign="top">%s</td>", $row ['alignment_id'] );
printf ( "<td align="center" valign="top">%s</td>", $row ['status_id'] );
print '</tr>';
}
print '</table>';
}
else
{
print '<span>There are no characters.</span><br />';
}
print '<br />';
returnmain();
}

function addcharacter() {
print '<h1 class="backstage">Character Management</h1><br />';
print '<h2 class="backstage">Add New Character</h2><br />';
print '<form name="addcharacter" method="post" action="backstage.php" id="addcharacter">';
print '<table width="100%" class="table2">';
print '<tr>';
print '<td class="rowheading">Character Name:</td><td class="row3">';
print '<input type="text" name="charactername" class="fieldtext490" value=""></td>';
print '</tr>';
print '<tr>';
print '<td width="120" class="rowheading">Username:</td><td class="row3"><input type="text" name="username" class="fieldtext160"></td>';
print '</tr>';
print '<tr>';
print '<td width="120" class="rowheading">Poser name:</td><td class="row3"><input type="text" name="posername" class="fieldtext160" value=""></td>';
print '</tr>';
print '<tr>';
print '<td class="rowheading">Style:</td>';
print '<td class="row3"><select name="style" class="selection"><option value="0">- Select -</option>';
print '<option value="Singles">Singles</option><option value="Tag Team">Tag Team</option><option value="Stable">Stable</option><option value="Manager">Manager</option><option value="Referee">Referee</option><option value="Staff">Staff</option>';
print '</select></td>';
print '</tr>';
print '<tr>';
print '<td class="rowheading">Gender:</td>';
print '<td class="row3"><select name="gender" class="selection"><option value="0">- Select -</option>';
print '<option value="Male">Male</option><option value="Female">Female</option>';
print '</select></td>';
print '</tr>';
print '<tr>';
print '<td class="rowheading">Status:</td>';
print '<td class="row3"><select name="status" class="selection"><option value="0">- Select -</option>';
print '<option value="Active">Active</option><option value="Inactive">Inactive</option>';
print '</select></td>';
print '</tr>';
print '<tr>';
print '<td class=rowheading>Division:</td>';
print '<td class=row3><select name=division class="selection"><option value=0>- Select -</option>';
print '</select></td>';
print '</tr>';
print '<tr>';
print '<td class=rowheading>Alignment:</td>';
print '<td class="row3"><select name="alignment" class="selection"><option value="0">- Select -</option>';
print '<option value="Face">Face</option><option value="Heel">Heel</option><option value="Neutral">Neutral</option>';
print '</select></td>';
print '</tr>';
print '<tr>';
print '<td class="rowheading">Sort:</td>';
print '<td class="row3"><select name="sort" class="selection"><option value=0>- Select -<option value="A">A<option value="B">B<option value="C">C<option value="D">D<option value="E">E<option value="F">F<option value="G">G<option value="H">H<option value="I">I<option value="J">J<option value="K">K<option value="L">L<option value="M">M<option value="N">N<option value="O">O<option value="P">P<option value="Q">Q<option value="R">R<option value="S">S<option value="T">T<option value="U">U<option value="V">V<option value="W">W<option value="X">X<option value="Y">Y<option value="Z">Z<option value="0-9">0-9</select></td>';
print '</tr>';
print '</table><br />';
print '<input type="submit" value="Save Character" class="button" name="addcharacter"><br /><br />';
print '<input type="button" value="Return to Character List" class="button200"><br /><br />';
print '<h2 class="backstage"><input type="button" value="Return to Main Menu" class="button200"></form></h2>';
}
?>

</body>
</html>

No comments posted yet

Your Answer:

Login to answer
212 Like 22 Dislike
Previous forums Next forums
Other forums

Mysql query, two times?
Hello to all,

I'm new to php coding and i like it alot. I need help with some noob stuff.

Random Number Generation And Probability
Hello, I am working on a function which has to insert data into a SQL table.

we have to suppl

How to get variable value on next page
Hello friends
i am working on payentry page ..there i have this code.........

Recognising Revenue daily
Hello.
Has anyone come across daily recognition of deferred income?
We want to implement R

PHP - HTML
Could anyone give me some GOOD sample links for php - html email tutorial.

Thanks!

help with multi-update
Now sure how to ask this really....
10g database if that matters.

I have a customer

Limiting checkboxes?
Hi guys,

I have this code: Code: if(isset($_POST['selected'])) {
foreach($_POST['selec

PHP Display Telephone Number On Referrer
I have used the php below to show a different telephone number in the header of the site depending u

PHP page loading in Firefox but not in IE
hello,

i am currently doing a project in PHP and i have a problem. If I view the project in M

Form validation with functions
Hi there

I am trying to make a very simple form validation function. I currently have the fol

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash