النتائج 1 إلى 7 من 7

الموضوع: [?] سؤال بخصوص تغيير الصورة عند الضغط عليها .

  1. #1
    عضو فعال
    تاريخ التسجيل
    Aug 2007
    المشاركات
    1,431

    Question [?] سؤال بخصوص تغيير الصورة عند الضغط عليها .



    السلام عليكم ورحمة الله وبركاته
    لدي استفسار بخصوص تغيير الصورة عند الضغط عليها

    أولاً لدي الدالتان :-
    كود PHP:

         <script type='text/javascript'>
         function pop(){
         window.open('<? print $option['site_url'].'/add-favorite-'.$GAMEID.'.html'?>','win','width=250 height=65');
         document.img1.src='<? print $option['site_url']; ?>/style/images/nofavorite.gif';
         document.img1.alt = 'Remove From Your Favorite Games';
         document.href1.href='xxxx.html';
         }
         function popx(){
         window.open('<? print $option['site_url'].'/remove-favorite-'.$GAMEID.'.html'?>','win','width=250 height=65');
         document.img2.src='<? print $option['site_url']; ?>/style/images/nofavorite.gif';
         document.img2.alt = 'Add to Your Favorite Games';
          }
         </script>
    ولدي الصورتان :
    كود PHP:

    <!-- {if $fav == 0} -->
     <
    a name="href1" href="javascript:pop();" onclick="document.this.url='xxx';" title="Add {$GAME.name} To Your Favorite Games" rel="nofollow">
    <
    img src="{$option.site_url}/style/images/favorite.gif" alt="Add To Your Favorite Games" border="0" name="img1">
    </
    a>
    <!-- {else} -->
    <
    a href="#" onclick="javascript:popx();document.img2.src='{$option.site_url}/style/images/favorite.gif';" title="Remove {$GAME.name} From Your Favorite" rel="nofollow">
    <
    img src="{$option.site_url}/style/images/nofavorite.gif" alt="Remove From Your Favorite Games" border="0" name="img2"></a>
    <!--  {/if} --> 
    طبعاً تلاحظون انها مع البي اتش بي ,,,
    يعني في حالة وجود اللعبه في مفضلة العضو تظهر له الصورة الثانيه nofavorite.gif اما إذا كانت غير موجوده في مفضلته فتظهر الصوره favorite.gif وعند الضغط عليها نطبق الدالة الأولى , ويتم تغيير الصورة بنجاح و الوصف ايضاً ,
    لكن المشكله ان الرابط لايتغير عند الضغط :eek3:
    أي ان document.href1.href='xxxx.html'; غير صحيح !

    وهذه هي المشكله بالتحديد , وشكراً.







  2. #2
    عضو فعال
    تاريخ التسجيل
    Aug 2007
    المشاركات
    1,431

  3. #3
    عضو جديد
    تاريخ التسجيل
    May 2007
    المشاركات
    13


    اخي العزيز انا شرحت تبديل الصور
    ياريت ترزور الرابط التالي
    http://dwal.biz/info-article-23.html






  4. #4
    عضو فعال
    تاريخ التسجيل
    Aug 2007
    المشاركات
    1,431


    جزاك الله خير وشكراً لردك
    بس تبديل الصور قمت بعمله بنجاح , مشكلتي هي بتغيير الرابط فقط






  5. #5
    عضو سوبر نشيط
    تاريخ التسجيل
    Aug 2007
    المشاركات
    674


    أخي استخدم getElementById

    كود PHP:
         <script type='text/javascript'>
         function pop(){
         window.open('<? print $option['site_url'].'/add-favorite-'.$GAMEID.'.html'?>','win','width=250 height=65');
         document.getElementById('img1').src='<? print $option['site_url']; ?>/style/images/nofavorite.gif';
         document.getElementById('img1').alt = 'Remove From Your Favorite Games';
         document.getElementById('myHref').href='xxxx.html';
         }
         function popx(){
         window.open('<? print $option['site_url'].'/remove-favorite-'.$GAMEID.'.html'?>','win','width=250 height=65');
         document.getElementById('img2').src='<? print $option['site_url']; ?>/style/images/nofavorite.gif';
         document.getElementById('img2').alt = 'Add to Your Favorite Games';
          }
         </script>
    كود PHP:
    <!-- {if $fav == 0} -->
     <
    a  ID="myHref" href="javascript:pop();" onclick="document.this.url='xxx';" title="Add {$GAME.name} To Your Favorite Games" rel="nofollow">
    <
    img  ID="img1" src="{$option.site_url}/style/images/favorite.gif" alt="Add To Your Favorite Games" border="0">
    </
    a>
    <!-- {else} -->
    <
    a href="#" onclick="javascript:popx();document.img2.src='{$option.site_url}/style/images/favorite.gif';" title="Remove {$GAME.name} From Your Favorite" rel="nofollow">
    <
    img  ID="img2" src="{$option.site_url}/style/images/nofavorite.gif" alt="Remove From Your Favorite Games" border="0"></a>
    <!--  {/if} --> 






    __________________
    Professional Java?Script Programmer and Web Developer

  6. #6
    عضو جديد
    تاريخ التسجيل
    May 2007
    المشاركات
    13


    اخي مشكلة تغير href
    عدم تعاملك بشكل صحيح مع الكود
    اول شي لازم اتحط
    معرف لل a
    كود PHP:
    id="d" 
    بعدها تشتغل عليه
    فلتغير الرابط تكتب
    كود PHP:
    document.getElementById('d')['href']="http://dwal.biz"
    مثال كامل
    كود PHP:
    <!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 content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <
    title>اضغط هنا</title>
    </
    head>

    <
    body>
    <
    a id="d" href="#" onclick="dd()" >اضغط هنا</a>
    <
    script type="text/javascript">
    <!--
    function 
    dd(){
    document.getElementById('d')['href']="http://dwal.biz";

    }
    //-->
    </script>
    </body>

    </html> 







  7. #7
    عضو فعال
    تاريخ التسجيل
    Aug 2007
    المشاركات
    1,431


    جزاكم الله خير
    الحمدلله اشتغل الكود تمااام

    وشكراً لكم .










ضوابط المشاركة

  • لا تستطيع إضافة مواضيع جديدة
  • لا تستطيع الرد على المواضيع
  • لا تستطيع إرفاق ملفات
  • لا تستطيع تعديل مشاركاتك
  •  

أضف موقعك هنا| اخبار السيارات | حراج | شقق للايجار في الكويت | بيوت للبيع في الكويت | دليل الكويت العقاري | مقروء | شركة كشف تسربات المياه | شركة عزل اسطح بالرياض | عزل فوم بالرياض| عزل اسطح بالرياض | كشف تسربات المياة بالرياض | شركة عزل اسطح بالرياض