Съвет за този код

wood

Registered
Как да преправя този код след като се зареди страницата да се показва само текста КУПИ, след като натисна бутона продай да се показва на негово място текста ПРОДАЙ, а купи да се скрива....в момента като се зареди страницата се показват и двата текста.


Това е кода:

<html>
<head>

<script type="text/javascript">
function callme(){
document.getElementById("hid").style.visibility="visible";
document.getElementById("hid2").style.visibility=" hidden";
}
function hideme(){
document.getElementById("hid").style.visibility=" hidden";
document.getElementById("hid2").style.visibility=" visible";
}
</script>

</head>
<body>
<form name="myform">

<table width="100%" border="4" cellpadding="2" cellspacing="2">
<tr>

</tr>
<tr style="visibility:none" id="hid">
<td width="17%" class="labeltext">Купи</td>
</tr>
<tr style="visibility:block" id="hid2">
<td width="17%" class="labeltext">Продай</td>

</td>
</tr>

</table>

<input type="button" onclick="callme()" value="Купи">
<input type="button" onclick="hideme()" value="Продай">

</form>
</body>
</html>
 
Справих се до тук...но защо след като сложа JS срипта между head ми дава грешка на страницата. Махам само скрипта и всичко е наред...
 
еми..
Код:
$(function () {


tuka javascript-a... 
i ..          $("#butona").click(function (){

          $("#poleto za skrivane/pokazvane").slideToggle();
});
});
 
Извинявай не но разбрах добре...Ето това е кода... Къде да поставя ???



<script type="text/javascript">
function callme(){
document.getElementById("hid").style.display="inline";
document.getElementById("hid2").style.display="none";
}
function hideme(){
document.getElementById("hid").style.display="none";
document.getElementById("hid2").style.display="inline";
}
</script>


<form name="myform">

<table width="100%" border="0" cellpadding="2" cellspacing="2">
<tr>

</tr>
<tr style="display:inline" id="hid">
<td width="17%" class="labeltext">Купи</td>
</tr>
<tr style="display:none" id="hid2">
<td width="17%" class="labeltext">Продай</td>

</tr>

</table>

<input type="button" onclick="callme()" value="Купи">
<input type="button" onclick="hideme()" value="Продай">

</form>
 
Я, пробвай така, на мен никакви грешки не ми дава.

Код:
<!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>
<title> Заглавие на страницата </title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<script type="text/javascript">
	function callme(){
	document.getElementById("hid").style.display="inline";
	document.getElementById("hid2").style.display="none";
	}
	function hideme(){
	document.getElementById("hid").style.display="none";
	document.getElementById("hid2").style.display="inline";
	}
	</script>
</head>
<form name="myform">

<table width="100%" border="0" cellpadding="2" cellspacing="2">
<tr>

</tr>
<tr style="display:inline" id="hid">
<td width="17%" class="labeltext">Купи</td>
</tr>
<tr style="display:none" id="hid2">
<td width="17%" class="labeltext">Продай</td>

</tr>

</table>

<input type="button" onclick="callme()" value="Купи">
<input type="button" onclick="hideme()" value="Продай">

</form>
 
Когато е на нова чиста страница няма никакъв проблем...но аз го вмъквам в началната страница index и тогава ми дава ето тази грешка.

Fatal error: Smarty error: [in main.tpl line 268]: syntax error: unrecognized tag: document.getElementById("hid").style.display="inline"; document.getElementById("hid2").style.display="none"; (Smarty_Compiler.class.php, line 439)
 
Това е кода на страницата на която искам да поставя...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="bg-BG" lang="bg-BG">
<head>
<title>
{if $TITLE ne ""}  {$TITLE} {/if}
</title>
<meta http-equiv="content-type" content="text/html;charset=windows-1251"/>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
<meta name="ROBOTS" content="All">
<meta name="revisit-after" content="2 days">


<link rel="StyleSheet" type="text/css" href="{image src="design.css"}" />
<script language="JavaScript" type="text/javascript" src="{image src='bookmarks.js'}"/></script>
<link rel="alternate" type="application/rss+xml" href="{$GLOBALS.site_url}/system/classifieds/last_listings_rss/?lang={$GLOBALS.current_language}" title="[[Last Listings:raw]]">
<link rel="alternate" type="application/rss+xml" href="{$GLOBALS.site_url}/system/classifieds/featured_listings_rss/?lang={$GLOBALS.current_language}" title="[[Featured ads:raw]]">


<head/>
<body><center><center/>



{literal}

<NOSCRIPT>
</br>
</br>
<table bgcolor="#FFFF00" cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr><td align="center"><font style="color:black;font-size:16px;">To use this site your Internet browser must have JavaScript enabled.</font></td></tr>
</table>
</NOSCRIPT>

<center>
<table bgcolor="#FFFF00" cellpadding="0" cellspacing="0" border="0" style="width:100%; display:none;" id="cookie_warning">
<tr><td align="center"><font style="color:black;font-size:16px;">To use this site your Internet browser must have Cookies enabled.</font></td></tr>
</table>
</center>
<script language="javascript">
if (!window.navigator.cookieEnabled || document.cookie=='')
{
document.getElementById("cookie_warning").style.di splay="block";
}
</script>
{/literal}
<div style="display:none;">

<img src="{image}find_home.jpg" alt="" />
<img src="{image}sell_house.jpg" alt="" />
</div>
<div class="main">
<div class="header">

{module name="menu" function="top_menu"}

</div>

<div class="content">
<div class="leftBlock">
{module name="menu" function="left_menu"}
{module name="menu" function="user_menu"}
<div class="pollBlock">
{module name="poll" function="poll_form"}
</div><br />
<div class="featuredAdsHeader">
<h3>[[Featured ads]]</h3>
</div>
<div class="featuredAdsKeep">
{$MAIN_CONTENT}
</div>

<br />


</div><br />

<div class="rightBlock" style="overflow:hidden;">
<div class="rightBlockCont">

<table cellpadding=0 cellspacing=0><tr><td>

<div class="quickSearch">
<div class="quickSearchHeader"><h3>[[Бързо търсене]]</h3></div>
<div class="quickSearchKeep" >
{module name="classifieds" function="search_form" form_template="quick_search.tpl" listing_type_id="HomesForSale"}
</div>
</div>

<div class="sellHome">
<div class="sellHomeHeader"><h3>[[Sell&Buy]]</h3></div>
<tr>
<td>


</td>
</tr>


</div>



</td></tr><tr><td style="padding-top:15px">

<div class="quickSearch">

<div class="quickSearchHeader"><h3>[[Homes by State]]</h3></div>

<div class="quickSearchKeep" >

{module name="classifieds" function="browse" level1Field='State' browse_template='browse_homes_by_state.tpl' listing_type_id='HomesForSale'}

</div>

</div>

<br>

<div class="quickSearch">

<div class="quickSearchHeader"><h3>[[Rentals by State]]</h3></div>

<div class="quickSearchKeep" >

{module name="classifieds" function="browse" level1Field='State' browse_template='browse_rentals_by_state.tpl' listing_type_id='HomesForRent'}

<br />

</div>

</div>



</td></tr></table>

</div>




<br />
<div class="featuredAdsHeader">
<h3>[[news]]</h3>
</div>



<script type="text/javascript">
function callme(){
document.getElementById("hid").style.display="inli ne";
document.getElementById("hid2").style.display="non e";
}
function hideme(){
document.getElementById("hid").style.display="none ";
document.getElementById("hid2").style.display="inl ine";
}
</script>

<form name="myform">
<input type="button" onclick="callme()" value="Купи">
<input type="button" onclick="hideme()" value="Продай">
<table width="100%" border="0" cellpadding="2" cellspacing="2">
<tr>

</tr>
<tr style="display:inline" id="hid">
<td width="17%" class="labeltext">Купи</td>
</tr>
<tr style="display:none" id="hid2">
<td width="17%" class="labeltext">Продай</td>

</tr>

</table>




</td>



</div>
</div>
<div class="clear_both"></div>
</div>

<table width=980 cellspacing=0 cellpadding=0 border=0 style="margin-top:10px;">
<tr>
<td style="padding-top:5px; padding-bottom:5px; border-top:#900 2px solid; border-bottom:">
 
<font style="color:#4D4D4D">Наши партньори:
</td>
</tr>
</table>

<div class="copyri">


</div>
</div>



</body>
</html>
 
Хайде колеги никой ли няма идея защо когато поствя скрипта на този код в индекса и ми дава грешка на страницата.

Скрипт:
<style>

</style>
<script src="http://code.jquery.com/jquery-1.4.4.js"></script>



<button id="hidr">Продай</button>
<button id="showr">Купи</button>

<div id="test1">Продайте</div>
<div id="test">Купи</div>
<script>
$(document).ready(function() {
$("#test1").hide();
});

$("#hidr").click(function () {
$("#test").hide();
$("#test1").show();
});

$("#showr").click(function () {
$("#test").show();
$("#test1").hide();
});

</script>

Грешка

Fatal error: Smarty error: [in main.tpl line 272]: syntax error: unrecognized tag: $("#test1").hide(); (Smarty_Compiler.class.php, line 439) in
 

Горе