הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   קוד ב JAVESCRIPT (https://hosts.co.il/forums/showthread.php?t=100566)

Resellers.co.il 21-10-12 13:28

קוד ב JAVESCRIPT
 
זה הקוד JS:
function showhide(id) {
if (document.getElementById(id).style.display == "none") {
document.getElementById(id).style.display = "inline"
}
else {
document.getElementById(id).style.display = "none";
}
}

וזה חלק מה-HTML:
<td><a href="#" onclick="javascript:showhide('picture1');">תמונה 1</a></td>
<td><a href="#" onclick="javascript:showhide('picture2');">תמונה 2</a></td>
<td><a href="#" onclick="javascript:showhide('picture3');">תמונה 3</a></td>
<td><a href="#" onclick="javascript:showhide('picture4');">תמונה 4</a></td>
<td><a href="#" onclick="javascript:showhide('picture5');">תמונה 5</a></td>

מה שהקוד הזה עושה בתכלס שאם לוחצים על הקישור תמונה 1: זה מציג תמונה, אם קישור תמונה 2 זה מציג אותה מתחתיה, אם אני לוחץ עוד פעם על 1 זה מוחק את התמונה 1.

אני רוצה שנגיד אני ילחץ 1 זה יציג לי את התמונה הראשונה, ונגיד אני ילחץ 2 זה יוריד תראשונה ויציג תתמונה השנייה, ז"א כל פעם תמונה אחרת שאני בוחר

bimbim 21-10-12 16:22

לפי סדר הלחיצות או לפי סדר התמונות?

Resellers.co.il 21-10-12 16:27

לפי סדר התמונות

eliran2313 21-10-12 17:05

תעלה בבקשה קוד html מלא של העמוד שלך.
כמה שיותר מהר בבקשה

Resellers.co.il 21-10-12 17:15

<body>
<div id="main">
<div id="menu">
<ul>
<?php include('blocks/menu.php'); ?>
</ul>
</div>
<div id="bg">
<div id="banner-m"></div>
<div id="text">
<p>גלריה</p>
</div>
<div id="paget"></div>
<div id="page">
<table>
<tr>
<td><a href="#" onclick="javascript:showhide('picture1');">תמונה 1</a></td>
<td><a href="#" onclick="javascript:showhide('picture2');">תמונה 2</a></td>
<td><a href="#" onclick="javascript:showhide('picture3');">תמונה 3</a></td>
<td><a href="#" onclick="javascript:showhide('picture4');">תמונה 4</a></td>
<td><a href="#" onclick="javascript:showhide('picture5');">תמונה 5</a></td>
</tr>
</table>
<br>
<table cellpadding="9" cellspacing="6" class="table" align="center">
<tr>
<td class="table" id="picture1" style="display:none;"><img src="http://www.introx-serv.co.il/img/1.png" border="0"></td>
<td class="table" id="picture2" style="display:none;"><img src="http://www.introx-serv.co.il/img/2.png" border="0"></td>
<td class="table" id="picture3" style="display:none;"><img src="http://www.introx-serv.co.il/img/3.png" border="0"></td>
<td class="table" id="picture4" style="display:none;"><img src="http://www.introx-serv.co.il/img/4.png" border="0"></td>
</tr>
</table>
</div>
</div>
</div>
</div>
</body>

eliran2313 21-10-12 17:42

ציטוט:

נכתב במקור על ידי Shahar Haronian (פרסם 860948)
<body>
<div id="main">
<div id="menu">
<ul>
<?php include('blocks/menu.php'); ?>
</ul>
</div>
<div id="bg">
<div id="banner-m"></div>
<div id="text">
<p>גלריה</p>
</div>
<div id="paget"></div>
<div id="page">
<table>
<tr>
<td><a href="#" onclick="javascript:showhide('picture1');">תמונה 1</a></td>
<td><a href="#" onclick="javascript:showhide('picture2');">תמונה 2</a></td>
<td><a href="#" onclick="javascript:showhide('picture3');">תמונה 3</a></td>
<td><a href="#" onclick="javascript:showhide('picture4');">תמונה 4</a></td>
<td><a href="#" onclick="javascript:showhide('picture5');">תמונה 5</a></td>
</tr>
</table>
<br>
<table cellpadding="9" cellspacing="6" class="table" align="center">
<tr>
<td class="table" id="picture1" style="display:none;"><img src="http://www.introx-serv.co.il/img/1.png" border="0"></td>
<td class="table" id="picture2" style="display:none;"><img src="http://www.introx-serv.co.il/img/2.png" border="0"></td>
<td class="table" id="picture3" style="display:none;"><img src="http://www.introx-serv.co.il/img/3.png" border="0"></td>
<td class="table" id="picture4" style="display:none;"><img src="http://www.introx-serv.co.il/img/4.png" border="0"></td>
</tr>
</table>
</div>
</div>
</div>
</div>
</body>

איפה ה js?
אני מבין שעברית זאת שפה קשה.
אנא ממך:
העתק את כל הקובץ, כולל כל הדברים, html css js php וכו' וכו' וכו'
ותדביק אותו בתוך תגיות code של פורום.
תודה

Resellers.co.il 21-10-12 17:46

body:
ציטוט:

<body>
<div id="main">
<div id="menu">
<ul>
<?php include('blocks/menu.php'); ?>
</ul>
</div>
<div id="bg">
<div id="banner-m"></div>
<div id="text">
<p>גלריה</p>
</div>
<div id="paget"></div>
<div id="page">
<table>
<tr>
<td><a href="#" onclick="javascript:showhide('picture1');">תמונה 1</a></td>
<td><a href="#" onclick="javascript:showhide('picture2');">תמונה 2</a></td>
<td><a href="#" onclick="javascript:showhide('picture3');">תמונה 3</a></td>
<td><a href="#" onclick="javascript:showhide('picture4');">תמונה 4</a></td>
<td><a href="#" onclick="javascript:showhide('picture5');">תמונה 5</a></td>
</tr>
</table>
<br>
<table cellpadding="9" cellspacing="6" class="table" align="center">
<tr>
<td class="table" id="picture1" style="display:none;"><img src="http://www.introx-serv.co.il/img/1.png" border="0"></td>
<td class="table" id="picture2" style="display:none;"><img src="http://www.introx-serv.co.il/img/2.png" border="0"></td>
<td class="table" id="picture3" style="display:none;"><img src="http://www.introx-serv.co.il/img/3.png" border="0"></td>
<td class="table" id="picture4" style="display:none;"><img src="http://www.introx-serv.co.il/img/4.png" border="0"></td>
</tr>
</table>
</div>
</div>
</div>
</div>
</body>
javescript:
ציטוט:

<script language="javascript">
function showhide(id) {
if (document.getElementById(id).style.display == "none") {
document.getElementById(id).style.display = "inline"
}
else {
document.getElementById(id).style.display = "none";
}
}
</script>

אדיר 21-10-12 19:31

בסוף הפונקציה תיצור משתנה שיכיל את האיידי שהועבר אליה,
בתחילת הפונקציה תבדוק אם המשתנה הזה קיים ואם כן תקבע עבור האלמנט עם האיידי הזה display none.

Resellers.co.il 22-10-12 16:30

ציטוט:

נכתב במקור על ידי xPerfection (פרסם 860958)
בסוף הפונקציה תיצור משתנה שיכיל את האיידי שהועבר אליה,
בתחילת הפונקציה תבדוק אם המשתנה הזה קיים ואם כן תקבע עבור האלמנט עם האיידי הזה display none.

אין לי מושג איך לירשום את זה ב JS.

IgalSt 22-10-12 23:52

ציטוט:

נכתב במקור על ידי Shahar Haronian (פרסם 861049)
אין לי מושג איך לירשום את זה ב JS.

קודים מוכנים זה לא פה.
אם אתה רוצה עזרה, תוכל לקבל עזרה ספציפית איך להתמודד עם מה שאתה צריך, אבל עליך להציג רצון ללמוד ולא רק עניין בקבלת הקוד העובד.

כך ש... במה נתקעת?


כל הזמנים הם GMT +2. הזמן כעת הוא 17:36.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ