Hi,
I'll try to explain as best as possible and hopefully it will make sense.
I've been looking into ways to build the content part of my site. The site uses html, css an php and uses absolute divs for header, footer and left nav pane, content scrolling in center.
The content part of the site needs to display text, forms, tables, images, feeds, php, mysql and is ok as is.
I'm looking at improving the performance by implementing js.
I understand I can use js for form validation, pop ups, alert windows, displaying dates, redirects, and calling different style sheets for different devices.
Question 1:
If I use js for form validation do I still need to validate it with php as well ?
Question 2:
Can js display all the content I need as outlined above in bold?
Question 3:
Can js replace the following bold php. Can it use the $result variable from the sql query and manipluate it the same as php does but with a js while statement and document.write instead of echo ?
if (! isset($_SESSION['user']) or (isset($_SESSION['user']) and ! ($_SESSION['user'] > 0)))
{
$query = "SELECT * FROM `quotes` WHERE `username` = '".$_SESSION['user']."' ";
$result = mysql_query ($query)or die (mysql_error());
while ($row = mysql_fetch_array($result)) // Can javascript do this ?
{?>
<table width='' border='0' bgcolor="#F3D673">
<tr>
<td align='left' valign='top' width='140'><strong>Quote ID:</strong></td>
<td align='left' valign='top' width='350'><b><?php echo $row['quoteid'];?></b></td></tr>
Question 4:
If I can is there any point, I use sessions and php needs to refresh the page anyway and the sql statement is the time consumer anyway!
Summary:
I use this js to output a single line change but cannot get it to work with forms or tables or returned table data after php manupulation ?
<div id="DivExample">
<a href="#self" onclick="document.getElementById('DivExample').innerHTML = 'This is the output of the javascript'; ">
This is an example of javascript</a>
</div>
I've tried lightboxes but again have problems with the light box not scrolling and I'm not sure if using a lightbox is correct anyway. I've also looked into ifames but don't know if thats correct.
Conclusion
I suppose I'm trying to define what language is appropriate for what functionality ? I'd like to use js as much as possible because client side is quicker but I'm strugglng to find where it is appropriate and where it isn't.
Any help would be much appreciated, I've already looked into loads of methods but still don't have a definitive answer.