![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
dc_jt
-
Posts
290 -
Joined
-
Last visited
Never
Posts posted by dc_jt
-
-
I tried that before posting but now the default date is todays date but 2006?
-
Hi I have the following which loops through the present year and adds two more years on:
However, I want it to be exactly the same but to start from last year rather than this year. Is this possible?
Thanks
<select name="sdatey" class="fmgreynormal"> <?php for ($i=date('Y');$i<=date('Y')+2;$i++) {?> <?php echo "<option value=\"$i\""; if ($_GET['iNewsId'] && formatDate($oObj->article_date) != '00/00/0000') { if ($i == $aYear) echo " selected"; echo ">$i</option>"; } else { if ($i == $year) echo " selected"; echo ">$i</option>"; } } ?> </select>
-
Thanks a lot, that worked
-
Ive posted this in the javascript forum too but there are no members in there so thought I would try here.
Ive done the following which works fine in Firefox but doesnt work at all in IE. Anyone know why?
Thanks
<script language="javascript"> function calculateTextBox(textBoxName, maximum){ length = document.getElementById(textBoxName).value.length; if(length > maximum){ document.getElementById(textBoxName).value = document.getElementById(textBoxName).value.substring(0, maximum); }else{ remaining = maximum - length; document.getElementById('text_limit_'+textBoxName).innerHTML = remaining ; } } </script> <td><strong>Short Description *</strong></td><td> <textarea class="txtarea400" style="width:100%; height:250;" rows="10" id="description" name="description" onkeyup="calculateTextBox('description', 200);"><?=(isset($_POST['description']))?stripslashes(htmlentities($_POST['description'])):htmlentities($oObj->description)?></textarea> Maximum 200 characters, <span id="text_limit_description" >200</span> remaining </td> </tr>
Thanks
-
Ive done the following which works fine in Firefox but doesnt work at all in IE. Anyone know why?
Thanks
<script language="javascript"> function calculateTextBox(textBoxName, maximum){ length = document.getElementById(textBoxName).value.length; if(length > maximum){ document.getElementById(textBoxName).value = document.getElementById(textBoxName).value.substring(0, maximum); }else{ remaining = maximum - length; document.getElementById('text_limit_'+textBoxName).innerHTML = remaining ; } } </script> <td><strong>Short Description *</strong></td><td> <textarea class="txtarea400" style="width:100%; height:250;" rows="10" id="description" name="description" onkeyup="calculateTextBox('description', 200);"><?=(isset($_POST['description']))?stripslashes(htmlentities($_POST['description'])):htmlentities($oObj->description)?></textarea> Maximum 200 characters, <span id="text_limit_description" >200</span> remaining </td> </tr>
Thanks
-
Got this function:
$aPara = 'this is my para? this is the second sent';
$aSent = split('[?!.]',$aPara);
print $aSent[0];
But it takes off the [?!.] at the end so its not perfect but might have to do
-
Hi
I have the following:
<?=strip_tags(substr($oTeam->description,0,140))?><?=(strlen($oTeam->description) > 140) ? '...' : ''?>
However, this displays the first 140 characters. I want to be able to display only the first sentence, basically everything upto the first full stop or question mark etc.
Any idea how?
Thanks
-
Thanks a lot, I used this method and it worked
Or...
printf(">%02d</option>",$i);
-
Hi
Probably a simple question but I have a date drop down which displays the days 1-31, however 1-9 are displayed 1,2,3,4,5,6,7,8,9 rather than 01, 02, 03, 04, 05, 06, 07, 08, 09.
So how do I get the 0 in front of each number?
Here is my code:
<td width="28%"><strong>Article Date</strong></td> <td><select name="sdated"> <? for ($i=1;$i<=31;$i++) {?><? echo "<option value=\"$i\""; if ($_GET['iNewsId'] && $oNewsArticle->formatted_article_date != '00/00/0000') { if ($i == $aDay) echo " selected"; echo ">$i</option>"; } else { if ($i == $day) echo " selected"; echo ">$i</option>"; } } ?> </select> <select name="sdatem"> <? for ($i=1;$i<=12;$i++) {?><? echo "<option value=\"$i\""; if ($_GET['iNewsId'] && $oNewsArticle->formatted_article_date != '00/00/0000') { if ($i == $aMonth) echo " selected"; echo ">$i</option>"; } else { if ($i == $month) echo " selected"; echo ">$i</option>"; } } ?> </select> <select name="sdatey"> <?php for ($i=date('Y');$i<=date('Y')+2;$i++) {?> <?php echo "<option value=\"$i\""; if ($_GET['iNewsId'] && $oNewsArticle->formatted_article_date != '00/00/0000') { if ($i == $aYear) echo " selected"; echo ">$i</option>"; } else { if ($i == $year) echo " selected"; echo ">$i</option>"; } } ?> </select> </td> </tr> </td> </tr>
-
Hi Im using the following date loop function and was just wondering if my function is correct?
Where I have for ($i=2007;$i<=date('Y')+4;$i++)
At the moment my drop down displays 2007 until 2011. Therefore, in 2008 will it display 2008 upto 2012 and so on.
<tr> <td width="28%">Date</td> <td><select name="sdated"> <? for ($i=1;$i<=31;$i++) {?><? echo "<option value=\"$i\""; if ($_GET['iNewsId'] && $oNewsArticle->formatted_date != '00/00/0000') { if ($i == $aDay) echo " selected"; echo ">$i</option>"; } else { if ($i == $day) echo " selected"; echo ">$i</option>"; } } ?> </select> <select name="sdatem"> <? for ($i=1;$i<=12;$i++) {?><? echo "<option value=\"$i\""; if ($_GET['iNewsId'] && $oNewsArticle->formatted_date != '00/00/0000') { if ($i == $aMonth) echo " selected"; echo ">$i</option>"; } else { if ($i == $month) echo " selected"; echo ">$i</option>"; } } ?> </select> <select name="sdatey"> <?php for ($i=2007;$i<=date('Y')+4;$i++) {?> <?php echo "<option value=\"$i\""; if ($_GET['iNewsId'] && $oNewsArticle->formatted_date != '00/00/0000') { if ($i == $aYear) echo " selected"; echo ">$i</option>"; } else { if ($i == $year) echo " selected"; echo ">$i</option>"; } } ?>
-
Hi
I have the following code which shows a div when you rollover the name. It all works, however when I first open the page, the div is shown, I need this hidden until someone rolls over a name.
Any idea how I can set it to be hidden straight away?
<?php require_once($_SERVER['DOCUMENT_ROOT'].'/config.inc.php'); require_once(LOCAL_CLASSES.'/Tables/RCLTblClients.class.php'); require_once(LOCAL_CLASSES.'/Tables/RCLTblClientsProjects.class.php'); $oTblClients = new RCLTblClients(); $oTblClientProjects = new RCLTblClientProjects(); $rClients = $oTblClients->GetClientsFront(); ?> <script language=javascript type='text/javascript'> function hideDiv(pass) { var divs = document.getElementsByTagName('div'); for(i=0;i<divs.length;i++){ if(divs[i].id.match(pass)){//if they are 'see' divs if (document.getElementById) // DOM3 = IE5, NS6 divs[i].style.display="none";// show/hide else if (document.layers) // Netscape 4 document.layers[divs[i]].display = 'none'; else // IE 4 document.all.hideShow.divs[i].display= 'none'; } } } function showDiv(pass) { var divs = document.getElementsByTagName('div'); for(i=0;i<divs.length;i++){ if(divs[i].id.match(pass)){ if (document.getElementById) divs[i].style.display=""; else if (document.layers) // Netscape 4 document.layers[divs[i]].display = ''; else // IE 4 document.all.hideShow.divs[i].display = ''; } } } </script> <? include($_SERVER['DOCUMENT_ROOT']."/includes/header.inc.php") ?><h1><img src="images/headers/clients.gif" alt="Clients" width="121" height="30" /></h1> <div id="contentareablank"> <div id="newsintrowrapper"> <div class="clear"></div> <!--<div id="clientsleft">--> <?php while ($oClient = mysql_fetch_object($rClients)) {?> <?php $counter++; if ($counter%2==0) $divid="clientsright"; else $divid="clientsleft";?> <div id="<?=$divid?>"> <div class="client"> <?php if($oClient->client_url){?> <a href="http://<?=$oClient->client_url?>" target="blank"> <?php }?> <?php if($oClient->client_url){?> </a> <?php }?> <p><strong> <?php if($oClient->client_url){?> <a href="http://<?=$oClient->client_url?>" target="blank"> <?php }?> <a href="#" onmouseover="javascript:showDiv('projects_<?=$oClient->client_id?>')" onmouseout="javascript:hideDiv('projects_<?=$oClient->client_id?>', 'projects_')"> <?=$oClient->name?> </a> <?php if($oClient->client_url){?> </a> <?php }?> </strong> <?=$oClient->content?></p> <?php $rProjects = $oTblClientProjects->GetProjectsForClient($oClient->client_id);?> <?php while ($oProjects = mysql_fetch_object($rProjects)) {?> <div class="clientsjobs" id="projects_<?=$oClient->client_id?>"> <ul> <li><?=$oProjects->ProjectName?></li> <!-- <li>Client job one</li> <li>Client job one</li> <li>Client job one</li> <li>Client job one</li> --> </ul> </div> <?php }?> </div> <div class="clear"></div> </div> <?php }?> <div class="clear"></div> </div> <div id="newsletter"> <fieldset> <label for="search">To recieve our email newsletter please enter your email address //</label> <input name="Keywords" id="search" value="Enter your email here" type="text" onfocus="if (this.value = 'Enter your email here') this.value = '';" /><input name="btnSearch" id="btnSearch" value="Go" class="formbutton" type="submit" /></fieldset></form></div> </div> </div> </div> <? include($_SERVER['DOCUMENT_ROOT']."/includes/footer.inc.php") ?>
Thanks
-
Hi I have the following code which works perfectly, however there are two headings - 'Special Offers' and 'Contact Us' which do not have any sub headings.
Once a heading is clicked the sub headings appear and the class changes to 'selected' (which is a down arrow).
When its not selected, it is an arrow pointing right.
At the moment, when I click Special Offers or Contact Us, the class still changes to 'selected' even if there is no sub links.
I want this to stay as the normal arrow.
How can I put that into the code below?
Thanks
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <HTML> <head> <script type="text/javascript"> function showHide(link) { var theDiv = document.getElementById(link.id + '_sub'); if(theDiv.style.display == 'block'){ theDiv.style.display = 'none'; link.className = ''; } else { theDiv.style.display = 'block'; link.className = 'selected'; hideOtherSubs(link); } } function hideOtherSubs(link){ var subs = new Array("resort_sub", "golf_sub", "special_sub", "business_sub", "occasions_sub", "relax_sub", "food_sub", "media_sub", "contact_sub"); var i; var tempLinkId; for(i = 0; i < subs.length; i++){ if(link.id + '_sub' != subs[i]){ document.getElementById(subs[i]).style.display = 'none'; tempLinkId = subs[i].substr(0, (subs[i].length - 4)); document.getElementById(tempLinkId).className = ''; } } } </script> <title></title> </head> <body> <div id="sidelinks"> <ul> <li><a href="#" id="resort" onclick="showHide(this); return false;">The Resort</a> </li></ul> <div id="resort_sub" style="display: none;"> <ul> <li class="sub"><a href="#" class="sub_link">- The Hotel</a></li> <li class="sub"><a href="#" class="sub_link">- Packages & Tarrifs</a></li> <li class="sub" style="margin-bottom:4px;"><a href="#" class="sub_link">- Guest Book</a></li> </ul></div> <ul><li> <a href="#" id="special" onclick="showHide(this); return false;">Special Offers</a> </li></ul> <div id="special_sub" style="display: none;"> </div> <ul> <li><a href="#" id="golf" onclick="showHide(this); return false;">Golf</a> </li></ul> <div id="golf_sub" style="display: none;"> <ul> <li class="sub"><a href="#" class="sub_link">- PGA Acadamy</a></li> <li class="sub"><a href="#" class="sub_link">- Golf Days</a></li> <li class="sub"><a href="#" class="sub_link">- The Old Course</a></li> <li class="sub"><a href="#" class="sub_link">- PGA Par 3 Course</a></li> <li class="sub"><a href="#" class="sub_link">- Memberships</a></li> <li class="sub"><a href="#" class="sub_link">- Golf Shop</a></li> <li class="sub" style="margin-bottom:4px;"><a href="#" class="sub_link">- Golf Packages</a> </ul></div> <ul> <li><a href="#" id="business" onclick="showHide(this); return false;">Business</a> </li></ul> <div id="business_sub" style="display: none;"> <ul> <li class="sub"><a href="#" class="sub_link">- Meetings & Events </a></li> <li class="sub"><a href="#" class="sub_link">- Room Capacities</a></li> <li class="sub" style="margin-bottom:4px;"><a href="#" class="sub_link">- Corporate Packages </a></li> </ul></div> <ul> <li> <a href="#" id="occasions" onclick="showHide(this); return false;">Occasions</a> </li></ul> <div id="occasions_sub" style="display: none;"> <ul> <li class="sub"><a href="#" class="sub_link">- Weddings</a></li> <li class="sub"><a href="#" class="sub_link">- Banqueting</a></li> <li class="sub"><a href="#" class="sub_link">- Private Dining </a></li> <li class="sub"><a href="#" class="sub_link">- Room Capacities</a></li> <li class="sub" style="margin-bottom:4px;"><a href="#" class="sub_link">- Occasion Packages</a></li> </ul></div> <ul> <li> <a href="#" id="relax" onclick="showHide(this); return false;">Relax</a> </li></ul> <div id="relax_sub" style="display: none;"> <ul> <li class="sub"><a href="#" class="sub_link">- Fitness & Leisure</a></li> <li class="sub"><a href="#" class="sub_link">- The Spa</a></li> <li class="sub" style="margin-bottom:4px;"><a href="#" class="sub_link">- Relax Packages</a></li> </ul></div> <ul> <li> <a href="#" id="food" onclick="showHide(this); return false;">Food & Drink</a> </li></ul> <div id="food_sub" style="display: none;"> <ul> <li class="sub"><a href="#" class="sub_link">- Restaurants</a></li> <li class="sub" style="margin-bottom:4px;"><a href="#" class="sub_link">- Bars</a></li> </ul></div> <ul> <li> <a href="#" id="media" onclick="showHide(this); return false;">Media Centre</a> </li></ul> <div id="media_sub" style="display: none;"> <ul> <li class="sub"><a href="#" class="sub_link">- News & Press</a> </li> <li class="sub"><a href="#" class="sub_link">- Press Enquiries </a></li> <li class="sub" style="margin-bottom:4px;"><a href="#" class="sub_link">- Image Gallery</a></li> </ul></div> <ul><li> <a href="#" id="contact" onclick="showHide(this); return false;">Contact Us</a> </li></ul> <div id="contact_sub" style="display: none;"> </div> <div class="clear"></div> <div class="clear"></div> </div> <div class="leftbox"> <div class="corner1"><img src="/images/blank.gif" alt=""/></div><div class="corner2"><img src="/images/blank.gif" alt=""/></div> <div class="middle"> <div class="middlewrapper"> <img src="/images/mailinglist.gif" alt="Mailing List" /> <input type="text" value="enter email" /><div style="float:left; width:55px;"><input type="button" class="button" style="width:50px;"value="Sign Up"/></div> <div style="float:left; width:20px; margin-top:2px;"><a href="#">Details</a></div> </div> </div> <div class="corner3"><img src="/images/blank.gif" alt=""/></div><div class="corner4"><img src="/images/blank.gif" alt=""/></div> </div> </body> </html>
-
Its Ok Ive sorted it
-
Everything is ok now regarding the styles and it passes validation etc. However, now when I click 'Business' for example, all the classes change to selected instead of just the business class??
Any idea why?
Here is my code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <HTML> <head> <script type="text/javascript"> function showHide(link) { var theDiv = document.getElementById(link.id + '_sub'); if(theDiv.style.display == 'block'){ theDiv.style.display = 'none'; link.className = ''; } else { theDiv.style.display = 'block'; link.className = 'selected'; hideOtherSubs(link); } } function hideOtherSubs(link){ var subs = new Array("resort_sub", "golf_sub", "special_sub", "business_sub", "occasions_sub", "relax_sub", "food_sub", "media_sub"); var i; var tempLinkId; for(i = 0; i < subs.length; i++){ if(link.id + '_sub' != subs[i]){ document.getElementById(subs[i]).style.display = 'none'; tempLinkId = subs[i].substr(0, (subs[i].length - 4)); document.getElementById(tempLinkId).className = 'selected'; } } } </script> <title></title> </head> <body> <div id="sidelinks"> <ul> <li><a href="#" id="resort" onclick="showHide(this); return false;">The Resort</a> </li></ul> <div id="resort_sub" style="display: none;"> <ul> <li class="sub"><a href="#" class="sub_link">- The Hotel</a></li> <li class="sub"><a href="#" class="sub_link">- Packages & Tarrifs</a></li> <li class="sub"><a href="#" class="sub_link">- Guest Book</a></li> </ul></div> <ul><li> <a href="#" id="special" onclick="showHide(this); return false;">Special Offers</a> </li></ul> <div id="special_sub" style="display: none;"> </div> <ul> <li><a href="#" id="golf" onclick="showHide(this); return false;">Golf</a> </li></ul> <div id="golf_sub" style="display: none;"> <ul> <li class="sub"><a href="#" class="sub_link">- PGA Acadamy</a></li> <li class="sub"><a href="#" class="sub_link">- Golf Days</a></li> <li class="sub"><a href="#" class="sub_link">- The Old Course</a></li> <li class="sub"><a href="#" class="sub_link">- PGA Par 3 Course</a></li> <li class="sub"><a href="#" class="sub_link">- Memberships</a></li> <li class="sub"><a href="#" class="sub_link">- Golf Shop</a></li> <li class="sub"><a href="#" class="sub_link">- Golf Packages</a> </ul></div> <ul> <li><a href="#" id="business" onclick="showHide(this); return false;">Business</a> </li></ul> <div id="business_sub" style="display: none;"> <ul> <li class="sub"><a href="#" class="sub_link">- Meetings & Events </a></li> <li class="sub"><a href="#" class="sub_link">- Room Capacities</a></li> <li class="sub"><a href="#" class="sub_link">- Corporate Packages </a></li> </ul></div> <ul> <li> <a href="#" id="occasions" onclick="showHide(this); return false;">Occasions</a> </li></ul> <div id="occasions_sub" style="display: none;"> <ul> <li class="sub"><a href="#" class="sub_link">- Weddings</a></li> <li class="sub"><a href="#" class="sub_link">- Banqueting</a></li> <li class="sub"><a href="#" class="sub_link">- Private Dining </a></li> <li class="sub"><a href="#" class="sub_link">- Room Capacities</a></li> <li class="sub"><a href="#" class="sub_link">- Occasion Packages</a></li> </ul></div> <ul> <li> <a href="#" id="relax" onclick="showHide(this); return false;">Relax</a> </li></ul> <div id="relax_sub" style="display: none;"> <ul> <li class="sub"><a href="#" class="sub_link">- Fitness & Leisure</a></li> <li class="sub"><a href="#" class="sub_link">- The Spa</a></li> <li class="sub"><a href="#" class="sub_link">- Relax Packages</a></li> </ul></div> <ul> <li> <a href="#" id="food" onclick="showHide(this); return false;">Food & Drink</a> </li></ul> <div id="food_sub" style="display: none;"> <ul> <li class="sub"><a href="#" class="sub_link">- Restaurants</a></li> <li class="sub"><a href="#" class="sub_link">- Bars</a></li> </ul></div> <ul> <li> <a href="#" id="media" onclick="showHide(this); return false;">Media Centre</a> </li></ul> <div id="media_sub" style="display: none;"> <ul> <li class="sub"><a href="#" class="sub_link">- News & Press</a> </li> <li class="sub"><a href="#" class="sub_link">- Press Enquiries </a></li> <li class="sub"><a href="#" class="sub_link">- Image Gallery</a></li> </ul></div> <ul> <li> <a href="#" >Contact Us</a></li><!--<li><a href="#" accesskey="7">Home</a></li>--> </ul> <div class="clear"></div> <div class="clear"></div> </div> <div class="leftbox"> <div class="corner1"><img src="/images/blank.gif" alt=""/></div><div class="corner2"><img src="/images/blank.gif" alt=""/></div> <div class="middle"> <div class="middlewrapper"> <img src="/images/mailinglist.gif" alt="Mailing List" /> <input type="text" value="enter email" /><div style="float:left; width:55px;"><input type="button" class="button" style="width:50px;"value="Sign Up"/></div> <div style="float:left; width:20px; margin-top:2px;"><a href="#">Details</a></div> </div> </div> <div class="corner3"><img src="/images/blank.gif" alt=""/></div><div class="corner4"><img src="/images/blank.gif" alt=""/></div> </div> </body> </html>
Thanks
-
Sorry Goose, it works perfectly in IE until I add my own styles.
I am putting a <div id="sidelinks"> at the very top and <li> before every <a href="#" id="resort" onclick="showHide(this); return false;">The Resort</a>
Is this OK or am I doing something wrong?
-
Fixed, thanks Goose
-
Works perfectly thank you Goose
-
Also, it doesnt seem to work in IE??
-
Sorry Goose Im back
Another thing I need to do is that when I click on another heading, the previous one closes?
Is this possible?
Thanks
-
Thank you so much. You are a genius Goose
Thanks again
DAvid
-
Sorry probably my fault.
For example, I have a menu on the left of my page with 3 headings, say heading 1, heading 2, heading 3.
When I click heading 1, heading sub1.1 and heading sub1.2 appear.
This all works fine with the script above.
However, I now want to do the same for heading 2 and heading 3.
Can I use the same showHide function or do I need to create individual ones for each heading?
Hope that makes more sense?
Thanks
-
Sorry not the class, I want to run the showHide function for about 5 different things??
-
Thanks alot goose, the link.className one worked perfectly
Now that was just for the 'The Resort' one, I have about five others that I want to do in the same way.
Do I have to do write out javascript for each one or is there a way I can use the same one?
Thanks
-
Ive got the following which when 'The Resort' is clicked the links below either appear or hide. This works fine, however I would like the class to also change to selected when the links are shown.
<script type="text/javascript"> function showHide(link) { var theDiv = link.parentNode.getElementsByTagName("div")[0]; if (link.innerHTML == "The Resort") { // show the div theDiv.style.display = ""; link.innerHTML = "The Resort "; } else { // hide the div theDiv.style.display = "none"; link.innerHTML = "The Resort"; } } </script> </head> <body> <div id="sidelinks"> <div class="additionalInfo"> <ul><li><a href="nojavascript.html" onclick="showHide(this);return false;">The Resort</a> <div style="display:none;"> <li class="sub"><a href="#" class="sub_link">- The Hotel</a></li> <li class="sub"><a href="#" class="sub_link">- Packages & Tarrifs</a></li> <li class="sub"><a href="#" class="sub_link">- Guest Book</a></li> </div> </div>
The above shows it with no class but I want it to be like this:
<ul><li><a href="nojavascript.html" class="selected" onclick="showHide(this);return false;">The Resort</a>
When the links are shown.
How can I do this?
Thanks
Starting a year loop with last year
in PHP Coding Help
Posted
Its ok Ive sorted it, thanks anyway