SitePoint Sponsor

User Tag List

Results 1 to 17 of 17

Hybrid View

  1. #1
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    JS functions don't always work

    Hi Everyone,

    I have a little problem which is bugging me.

    I am building a site which works with Smarty and many PHP include files. I'm using many Javascript functions all over the site for validating forms, etc...

    So I have a "header.php" file with the following :

    HTML Code:
    <script language="javascript" type="text/javascript" src="js/validations.js"></script>
    ...and then I have another Smarty template file named "edit_account_pers.tpl" with the following line of code :

    HTML Code:
    <form name="edit_pers" onsubmit="return validateeditpers()" action="{$domain}/{$edit_account_process}" method="post">
    I'm assuming that the Smarty doesn't have anything to do with this, but it simply doesn't work. I have many other validation functions in that same "validations.js" file that work perfectly fine on other forms on the site.

    Here is the function for this specific form :

    HTML Code:
    function validateeditpers()  {  	valid = true;  	  	if (document.edit_pers.fname.value == "")  	{  		alert ("Please fill in your first name!");  		valid = false;  		document.edit_pers.fname.focus();  		return valid;  	}  	  	if (document.edit_pers.lname.value == "")  	{  		alert ("Please fill in your last name!");  		valid = false;  		document.edit_pers.lname.focus();  		return valid;  	}  	  	return valid;  }
    I'm getting frustrated, since I need it to work.
    Does anyone have an idea why this doesn't work? It's so simple, and my other validation functions work on the same principle. Maybe I'm missing something here...

    Thanks for any advice.

    All the best,
    Antonie
    And so I got lost in code...completely asphyxiated by it...

    Premium WordPress plugins - Tribulant Software

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,861
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The way that script tag is coded it will pull from different folders depending on where the page is located. Try adding a / to the front so as to change ot to relative to the domain root folder rather than relative to the current page location.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi Stephen,

    Thanks for the response. I'm getting really frustrated, and I really don't know what the problem is.

    So you think it could be the Smarty .tpl display files that cause the JS not to load correctly due to the change in directory? I realize that the template file is way out in another location, but the main .php file which calls the template file is correctly configured with the path of the JS file.

    What I did...
    I figured that since each validation function will only count for that specific form or template file, I could just as well include the JS into the '.tpl' itself. With Smarty, I can use {literal}<script type="......> *code* </script>{/literal}. This works perfectly, and the JS function which is called by the HTML is inside that file itself.

    I haven't checked whether this causes validation problems with HTML output...but it should be fine after all. What do you think?

    Thanks again!
    Antonie
    And so I got lost in code...completely asphyxiated by it...

    Premium WordPress plugins - Tribulant Software

  4. #4
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ignoring the PHP side for now, when you visit a page that "does not work" (javascript error??) and view source, is everything properly in place?

    One way to check the directory is browse to a page that doesn't work, view source and look at the path to the js file in the <script> tag, let's say it's js/validations.js

    Append that to the path of the current URL and try browsing to it - it will either try to dowload the JS (success) or 404 if it's wrong.

  5. #5
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Yes, the paths match up perfectly.

    I have a file with the following web URL :

    http://www.yoursite.com/account.php

    This file includes a header. The <script> tag with the source path is inside the header. When I view the source of the "account.php" page, I can see the <script> tag, and I can append the source path to the web URL and see the JS.

    Strange...

    Could it be cache on my side? Or... 'include_once()'

    I mainly use Opera these days, so there is no way to see the JS errors, but in IE it says 'Object Needed' (or something). I'm not a JS guru, so I honestly can't tell what this is.
    And so I got lost in code...completely asphyxiated by it...

    Premium WordPress plugins - Tribulant Software

  6. #6
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK so it's a javascript error - view source and post the code here.

    PS if you can please also post the exact error message

  7. #7
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I can't imagine that there is something wrong with the code, but if IE says so, then it must be. (something I overlooked.)

    HTML Code:
    function validateeditpers()
    {
    	valid = true;
    	
    	if (document.edit_pers.fname.value == "")
    	{
    		alert ("Please fill in your first name!");
    		valid = false;
    		document.edit_pers.fname.focus();
    		return valid;
    	}
    	
    	if (document.edit_pers.lname.value == "")
    	{
    		alert ("Please fill in your last name!");
    		valid = false;
    		document.edit_pers.lname.focus();
    		return valid;
    	}
    	
    	return valid;
    }
    Thanks for your help. I'm sure you will be able to help me troubleshoot and get it right.
    And so I got lost in code...completely asphyxiated by it...

    Premium WordPress plugins - Tribulant Software

  8. #8
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    This is the error which IE gives me. It happens when the form gets submitted...and the JS function gets executed with the 'onsubmit()' command.
    Attached Images Attached Images
    And so I got lost in code...completely asphyxiated by it...

    Premium WordPress plugins - Tribulant Software

  9. #9
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the function is fine but "object needed" suggests that the form elements lname and /or fname don't exist. If you can't figure it out you will have to post the full html from view source.

  10. #10
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    All the code is up there in the first post, but it all came out as one liners. Here is the HTML code of the '.tpl' file.

    HTML Code:
    <span class="textblue"><b>Edit your CalBBQ account :</b></span><br/><br/>
    Use the form below to edit your personal CalBBQ account.<br/><br/>
    <form name="edit_pers" onsubmit="return validateeditpers()" action="{$domain}/{$edit_account_process}" method="post">
    <b>First Name :</b><br/>
    <input type="text" class="input" size="25" name="fname" value="{$session_fname}" /><br/><br/>
    <b>Last Name :</b><br/>
    <input type="text" class="input" size="25" name="lname" value="{$session_lname}" /><br/><br/>
    <input type="image" src="{$domain}/images/buttons/submit.gif" name="submit" value="submit" />
    </form>
    I was thinking...
    Maybe I should use ID's and then use 'getElementById()' in the JS function. This could solve the problem. (i think)
    And so I got lost in code...completely asphyxiated by it...

    Premium WordPress plugins - Tribulant Software

  11. #11
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Just tried that...and it still doesn't work. I assigned an ID to each of the input fields, and then pointed to them in the JS function using 'getElementById()'

    Could it be some sort of conflict with other JS on the page? I've had that before.
    And so I got lost in code...completely asphyxiated by it...

    Premium WordPress plugins - Tribulant Software

  12. #12
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please post "view source" html not the tpl stuff - there might be a strange value in one of your tpl variables that's causing this to fail.

  13. #13
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi there,

    Here is the full source of the page. You'll notice that I have added the JS right beneath the form for now, and it works...but I'd prefer to have it in the external JS file.

    HTML 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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>CalBBQ - Barbeques, Outdoor Kitchens, Patio Furniture, Built-in Grills and Accessories</title>
    
    <script language="javascript" type="text/javascript" src="js/divs.js"></script>
    <script language="javascript" type="text/javascript" src="js/validations.js"></script>
    <script language="javascript" type="text/javascript" src="js/functions.js"></script>
    <script language="javascript" type="text/javascript" src="js/flashobject.js"></script>
    <script language="javascript" type="text/javascript" src="js/navigation.js"></script>
    
    <style type="text/css">
    <!--
    
    @import "css/nav_style.css";
    @import "css/style.css";
    @import "css/sweetTitles.css";
    
    -->
    </style>
    
    </head>
    
    <body style="margin:20px" onload="MM_preloadImages('images/navigation/nav1_over.gif','images/navigation/nav2_over.gif','images/navigation/nav3_over.gif','images/navigation/nav4_over.gif')">
    
    <form name="searchform" action="search.php" method="post">
    <input id="string" type="hidden" name="string" value="" />
    </form>
    
    
    <div align="center">
    
    <table cellpadding="0" cellspacing="0" style="width:800px">
    <tr>
    <td style="width:300px"><div align="justify"><a href="http://www.calbbq.com"><img style="border:0" src="images/calbbq_logo.gif" alt="CalBBQ&nbsp;-&nbsp;Barbeque,&nbsp;Spas,&nbsp;Outdoor&nbsp;Kitchens,&nbsp;Patio&nbsp;Furniture,&nbsp;and&nbsp;Accessories" /></a></div></td>
    
    <td style="width:0px"></td>
    
    <td align="right" style="width:500px" valign="top">
    <div align="right" class="textblack">
    
    	<table cellpadding="0" cellspacing="0">
    	<tr>
    	<td valign="top" align="left" style="height:55px">
    
    	
    		<table cellpadding="0" cellspacing="0">
    		<tr>
    		
    		<td valign="top" align="right">
    		Welcome back <b>Antonie Potgieter</b>!<br/><br/>
    		<a href="http://www.calbbq.com/account.php" class="textblack_links"><img src="images/icons/ico_user_account.gif" border="0" alt="Your&nbsp;Account" />&nbsp;Your Account</a>
    		&nbsp;&nbsp;&zwnj;&nbsp;&nbsp;
    		<a href="http://www.calbbq.com/cart.php" class="textblack_links"><img src="images/icons/ico_cart.gif" border="0" alt="Shopping&nbsp;Cart" />&nbsp;Shopping Cart</a>
    		&nbsp;&nbsp;&zwnj;&nbsp;&nbsp;
    		<a href="http://www.calbbq.com/logout.php" class="textblack_links"><img src="images/icons/ico_user_logout.gif" border="0" alt="User&nbsp;Logout" />&nbsp;Logout</a>
    		</td>
    		
    		</tr>
    		</table><br/><br/>
    			
    	</td>
    	</tr>
    	</table>
    	
    	<div style="height:40px">
    	<table cellpadding="0" cellspacing="0" style="height:40px">
    	<tr>
    	
    	<td><a title="Register for your own personal CalBBQ account today." href="http://www.calbbq.com/register.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('nav1','','images/navigation/nav1_over.gif',1)"><img src="images/navigation/nav1_up.gif" alt="register" name="nav1" width="75" height="40" border="0" id="nav1" /></a></td>
    	<td><a title="Go to the CalBBQ home page." href="http://www.calbbq.com/index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('nav2','','images/navigation/nav2_over.gif',1)"><img src="images/navigation/nav2_up.gif" alt="CalBBQ&nbsp;Home" name="nav2" width="64" height="40" border="0" id="nav2" /></a></td>
    	<td><a title="Read more about the CalBBQ company." href="http://www.calbbq.com/about.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('nav3','','images/navigation/nav3_over.gif',1)"><img src="images/navigation/nav3_up.gif" alt="CalBBQ&nbsp;About&nbsp;Us" name="nav3" width="79" height="40" border="0" id="nav3" /></a></td>
    	<td><a title="Contact the support department with a question, query or request." href="http://www.calbbq.com/contact.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('nav4','','images/navigation/nav4_over.gif',1)"><img src="images/navigation/nav4_up.gif" alt="CalBBQ&nbsp;Contact&nbsp;Us" name="nav4" width="86" height="40" border="0" id="nav4" /></a></td>
    	<td style="background-image:url(images/navigation/nav_rep.gif) ; width:10px"></td>
    	
    	<td style="padding-top:5px ; padding-bottom:8px ; background-image:url(images/navigation/nav_rep.gif)">
    	<input id="search_string" type="text" class="input" size="15" name="search_string" />
    	<input onclick="return search_form()" type="submit" name="submit" value="Go" /></td>
    	
    	<td style="background-image:url(images/navigation/nav_right.gif) ; width:11px">&nbsp;&nbsp;</td>
    	
    	</tr>
    	</table>
    	</div>
    	
    </div>
    </td>
    
    </tr>
    </table><br/>
    
    <table cellpadding="0" cellspacing="0" style="width:800px">
    <tr>
    <td align="left">
    <div align="justify" style="background-color:#006699 ; width:800px ; height:20px">
    
    <ul id="nav">
    
    	<li><a href="products.php?method=0d70c0c56a180b18d01d9f553d18f7b9&amp;main_id=1">&nbsp;&nbsp;Barbeques</a><ul><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=2">Cal&nbsp;Flame</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=13">Fire&nbsp;Magic</a></li></ul></li><li><a href="products.php?method=0d70c0c56a180b18d01d9f553d18f7b9&amp;main_id=2">&nbsp;&nbsp;Outdoor&nbsp;Kitchens</a><ul><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=28">$5000&nbsp;and&nbsp;below</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=29">$5000&nbsp;to&nbsp;$10,000</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=31">Over&nbsp;$10,000</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=33">Totally&nbsp;Custom&nbsp;Islands</a></li></ul></li><li><a href="products.php?method=0d70c0c56a180b18d01d9f553d18f7b9&amp;main_id=3">&nbsp;&nbsp;Hardware</a><ul><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=18">Accessories</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=11">Cocktail&nbsp;Centers</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=12">Doors&nbsp;&amp;&nbsp;Drawers</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=14">Kegerators</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=15">Refrigerator</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=17">Side&nbsp;Burners</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=16">Sinks</a></li></ul></li><li><a href="products.php?method=0d70c0c56a180b18d01d9f553d18f7b9&amp;main_id=4">&nbsp;&nbsp;Patio&nbsp;Furniture</a><ul><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=25">Accessories</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=19">Chairs</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=24">Couches&nbsp;and&nbsp;Loveseats</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=20">Loungers</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=26">Sunbrella&nbsp;Cushions</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=22">Tables</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=27">Umbrellas</a></li></ul></li><li><a href="products.php?method=0d70c0c56a180b18d01d9f553d18f7b9&amp;main_id=5">&nbsp;&nbsp;Spas&nbsp;&amp;&nbsp;Jacuzzis</a><ul><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=7">Accessories</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=8">Chemicals</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=9">Spas</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=32">Swim&nbsp;Spas</a></li></ul></li><li><a href="products.php?method=0d70c0c56a180b18d01d9f553d18f7b9&amp;main_id=6">&nbsp;&nbsp;Gazebos</a><ul><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=3">Accessories</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=4">Gazebos</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=5">Spa&nbsp;Wraps</a></li><li><a href="products.php?method=f996aba6f29370598abba749ea1fc5a1&amp;sub_id=6">Surround&nbsp;Packages</a></li></ul></li>
    </ul>
    
    </div>
    </td>
    </tr>
    </table><br/>
    <table cellpadding="0" cellspacing="0" style="width:800px">
    <tr>
    
    <td style="width:200px" valign="top">
    <div align="justify">
    <table cellpadding="0" cellspacing="0" style="width:200px">
    
    <tr>
    <td style="height:33px ; background-image:url(images/side_top.gif)">
    <div align="justify" style="padding-left:10px ; padding-right:5px ; padding-top:5px ; padding-bottom:5px">
    <span class="textblue"><b>News &amp; Information</b></span>
    </div>
    </td>
    </tr>
    
    <tr><td style="background-image:url(images/side_rep_top.gif) ; height:1px"></td></tr>
    
    <tr>
    <td style="background-image:url(images/side_rep.gif)">
    <div align="justify" style="padding:10px">
    <b>Forums</b><br/>
    Browse through our latest forums and expand your knowledge on the latest in outdoor living.<br/>
    <a href="http://forums.calbbq.com" class="textblue_links">Forums ></a><br/><br/>
    <b>Specials</b><br/>
    Now for a limited time get free shipping on all built in Cal Flame grills we carry!<br/>
    <a href="#" class="textblue_links">Specials ></a><br/><br/>
    </div></td></tr>
    
    <tr><td style="background-image:url(images/side_rep_bottom.gif) ; height:3px"></td></tr>
    
    <tr><td><br/></td></tr>
    
    <tr>
    <td style="height:33px ; background-image:url(images/side_top.gif)">
    <div align="justify" style="padding-left:10px ; padding-right:5px ; padding-top:5px ; padding-bottom:5px">
    <span class="textblue"><b>Latest Products</b></span>
    </div>
    </td>
    </tr>
    
    <tr><td style="background-image:url(images/side_rep_top.gif) ; height:1px"></td></tr>
    
    <tr>
    <td style="background-image:url(images/side_rep.gif)">
    <div align="justify" style="padding:10px">
    
    
    	<div style="display:block ; padding:5px">
    	<a href="products.php?method=ba389887bb292d0f29006243ea584aa8&amp;prod_id=30" class="textblack_links">Custom Islands</a></div>
    	
    	<div style="display:block ; padding:5px">
    	<a href="products.php?method=ba389887bb292d0f29006243ea584aa8&amp;prod_id=29" class="textblack_links">Stainless Steel Refrigerator</a></div>
    	
    	<div style="display:block ; padding:5px">
    	<a href="products.php?method=ba389887bb292d0f29006243ea584aa8&amp;prod_id=28" class="textblack_links">U8900 Barbecue Island</a></div>
    	
    </div>
    </td>
    </tr>
    
    <tr><td style="background-image:url(images/side_rep_bottom.gif) ; height:3px"></td></tr>
    
    <tr><td><br/></td></tr>
    
    <tr>
    <td style="height:33px ; background-image:url(images/side_top.gif)">
    <div align="justify" style="padding-left:10px ; padding-right:5px ; padding-top:5px ; padding-bottom:5px">
    <span class="textblue"><b>CalBBQ Support</b></span>
    </div>
    </td>
    </tr>
    
    <tr><td style="background-image:url(images/side_rep_top.gif) ; height:1px"></td></tr>
    
    <tr>
    <td style="background-image:url(images/side_rep.gif)">
    <div align="center" style="padding:10px">
    <style type="text/css"><!-- #surveyDiv {position:absolute; height:1; width:1; top:0; left:0;} --></style><script language="JavaScript" src="http://www.calbbq.com/phplive/web/Adam/surveys.php?base_url=http://www.calbbq.com/phplive"></script><script language="JavaScript" src="http://www.calbbq.com/phplive/js/status_image.php?base_url=http://www.calbbq.com/phplive&l=Adam&x=1&deptid=1&btn=1"></script><div id="surveyDiv" style="visibility:hidden"></div>
    </div>
    </td>
    </tr>
    
    <tr><td style="background-image:url(images/side_rep_bottom.gif) ; height:3px"></td></tr>
    
    <tr><td><br/></td></tr>
    
    <tr>
    <td style="height:33px ; background-image:url(images/side_top.gif)">
    <div align="justify" style="padding-left:10px ; padding-right:5px ; padding-top:5px ; padding-bottom:5px">
    <span class="textblue"><b>Payment Methods</b></span>
    </div>
    </td>
    </tr>
    
    <tr><td style="background-image:url(images/side_rep_top.gif) ; height:1px"></td></tr>
    
    <tr>
    <td style="background-image:url(images/side_rep.gif)">
    <div align="center" style="padding:10px">
    <img src="images/cards.gif" alt="cards" />
    </div>
    </td>
    </tr>
    
    <tr><td style="background-image:url(images/side_rep_bottom.gif) ; height:3px"></td></tr>
    
    </table></div>
    </td>
    
    <td style="width:10px"></td>
    
    <td valign="top">
    <div class="content1" align="justify">
    
    <span class="textblue"><b>Edit your CalBBQ account :</b></span><br/><br/>
    Use the form below to edit your personal CalBBQ account.<br/><br/>
    <form name="edit_pers" onsubmit="return validateeditpers()" action="http://www.calbbq.com/account.php?method=edit_acc_pers_process" method="post">
    <b>First Name :</b><br/>
    <input type="text" class="input" size="25" name="fname" value="Antonie" /><br/><br/>
    <b>Last Name :</b><br/>
    <input type="text" class="input" size="25" name="lname" value="Potgieter" /><br/><br/>
    <b>Email Address :</b><br/>
    <input type="text" class="input" size="30" name="email" value="antonie@contrid.com" /><br/><br/>
    <b>Company :</b><br/>
    <input type="text" class="input" size="30" name="company" value="Contrid Intelligence" /><br/><br/>
    <input type="image" src="http://www.calbbq.com/images/buttons/submit.gif" name="submit" value="submit" />
    </form>
    
    
    <script language="javascript" type="text/javascript">
    <!--
    
    function validateeditpers()
    {
    	valid = true;
    	
    	if (document.edit_pers.fname.value == "")
    	{
    		alert ("Please fill in your first name!");
    		valid = false;
    		document.edit_pers.fname.focus();
    		return valid;
    	}
    	
    	if (document.edit_pers.lname.value == "")
    	{
    		alert ("Please fill in your last name!");
    		valid = false;
    		document.edit_pers.lname.focus();
    		return valid;
    	}
    	
    	if (document.edit_pers.email.value == "")
    	{
    		alert ("Please fill in an email address!");
    		valid = false;
    		document.edit_pers.email.focus();
    		return valid;
    	}
    	
    	if (document.edit_pers.email.value != "")
    	{
    		var at = "@";
    		var dot = ".";
    		
    		if (document.edit_pers.email.value.indexOf(at) == -1 || document.edit_pers.email.value.indexOf(dot) == -1)
    		{
    			alert ("Please fill in a valid email address!");
    			valid = false;
    			document.edit_pers.email.focus();
    			return valid;
    		}
    	}
    	
    	return valid;
    }
    
    -->
    </script>
    
    </div>
    </td>
    
    </tr>
    </table>
    
    <br/>
    
    <table cellpadding="0" cellspacing="0" style="width:800px">
    <tr>
    <td>
    <div style="background-color:#006699 ; border-top:1px #969593 solid ; border-bottom:1px #969593 solid ; padding-top:5px ; padding-bottom:5px ; padding-left:10px ; padding-right:10px" align="justify" class="textwhite">
    <a href="http://www.calbbq.com/index.php" class="textwhite_links">Home</a>&nbsp;&nbsp;&zwnj;&nbsp;&nbsp;
    <a href="http://www.calbbq.com/register.php" class="textwhite_links">Register</a>&nbsp;&nbsp;&zwnj;&nbsp;&nbsp;
    <a href="http://www.calbbq.com/login.php" class="textwhite_links">Login</a>&nbsp;&nbsp;&zwnj;&nbsp;&nbsp;
    <a href="http://www.calbbq.com/about.php" class="textwhite_links">About Us</a>&nbsp;&nbsp;&zwnj;&nbsp;&nbsp;
    <a href="http://www.calbbq.com/contact.php" class="textwhite_links">Contact Us</a>
    </div><br/>
    <div align="center" class="textblack">All rights reserved and copyright &copy; 2006 <b>CalBBQ</b><br/><br/><br/>
    
    
    </div><br/><br/>
    </td>
    </tr>
    </table><br/>
    
    </div>
    
    </body>
    
    </html>
    And so I got lost in code...completely asphyxiated by it...

    Premium WordPress plugins - Tribulant Software

  14. #14
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,861
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    If it works below the form but not in the head then it is a timing problem since Javascript cannot access the content of the page before that content has finished loading. To fix this you need to either use the onload event handler to trigger the processing after the whole page has loaded or set up a loop that keeps testing for if the particular objects have loaded and which doesn't try to update them until they have loaded.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  15. #15
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I have to thank you for all your help! You made me realize something.

    I'm not sure if you're familiar with PHP, but basically I have a 'switch()' statement in the body section of my code, with a bunch of functions at the top of the <DOCTYPE...> tag. The 'header.php' include is only after these functions...and even though the functions output inside the body, they seem to be loading before the 'header.php' file is included.

    Solution :
    All I did was move the
    PHP Code:
    <?php include 'header.php'?>
    to the top of the page above all the functions called by my 'switch()' statement.

    Thanks again for the help!
    And so I got lost in code...completely asphyxiated by it...

    Premium WordPress plugins - Tribulant Software

  16. #16
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was going to say, the HTML and javascript all worked fine for me

    Good job.

  17. #17
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Yeah...the code was fine.

    I don't work with Javascript that much (yet). I've been trying to teach myself as much as I possibly can over the past month or so.

    I've never had this problem with stylesheets though...so I guess it's just JS.

    Once again thanks for the time you took to try and help me out. I appreciate it. Chances are that you will see me here again with more JS questions since it's a learning process for me...but I'm really enjoying this powerful scripting language.

    All the best,
    Antonie
    And so I got lost in code...completely asphyxiated by it...

    Premium WordPress plugins - Tribulant Software


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •