佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 811|回复: 11

Javascript 问题

[复制链接]
晓思 该用户已被删除
发表于 11-7-2006 04:54 PM | 显示全部楼层 |阅读模式
function check()
{
        ReturnVal = 0;
        for (var i = 1; i<document.ProdUpload.elements.length; i++)
        {
                if ((document.ProdUpload.elements.type == "file")
                {   
                     ReturnVal = 1;
                     a = i - 2;
                     b = i - 1;
                     ImageValue = document.ProdUpload.elements.value;
                            ProdName = document.ProdUpload.elements[a].value;
                            ProdDescp = document.ProdUpload.elements.value;

                            if ((!(ImageValue == ""))
                            {
                         ProdCheck(ProdName);

                         if (count == 1 )
                         {
                                document.ProdUpload.elements[a].focus();
                                return false;
                          }
                             }
                  }
               }

              if (count=="0"
              {
            alert("there";
            return true;
            alert("hello";
              }
    }

function ProdCheck(str)
{
     count = 0;

     if (str == ""
     {
         count = 1;
         alert("lease enter Product Name"
         document.ProdUpload.elements[a].focus();
         return false;
      }
      
     return true;

}

为甚么我不能return 呢? 谢谢.........

[ 本帖最后由 晓思 于 11-7-2006 05:02 PM 编辑 ]
回复

使用道具 举报


ADVERTISEMENT

发表于 11-7-2006 06:22 PM | 显示全部楼层
可以放在[code][/code]里面吗?

很多mistakes啊。。。还有你的local variable和global variable要弄清楚一点.....
回复

使用道具 举报

晓思 该用户已被删除
 楼主| 发表于 12-7-2006 10:02 AM | 显示全部楼层
有人可以帮我吗? 很急....我的return.....好象不能function... return true 因该可以帮我去另一个page...
回复

使用道具 举报

发表于 12-7-2006 03:10 PM | 显示全部楼层

  1. function check()
  2. {
  3.         ReturnVal = 0;
  4.         for (var i = 1; i<document.ProdUpload.elements.length; i++)
  5.         {               
  6.                 if ((document.ProdUpload.elements.type == "file")) //document.ProdUpload.elements 应该是ARRAY?
  7.                 {   
  8.                         ReturnVal = 1;
  9.                         a = i - 2;
  10.                         b = i - 1;
  11.                         ImageValue = document.ProdUpload.elements.value; //document.ProdUpload.elements 应该是ARRAY?
  12.                         ProdName = document.ProdUpload.elements[a].value;
  13.                         ProdDescp = document.ProdUpload.elements.value; //document.ProdUpload.elements 应该是ARRAY?
  14.                        
  15.                         if ((!(ImageValue == "")))
  16.                         {
  17.                                 ProdCheck(ProdName);
  18.                                
  19.                                 if (count == 1 )
  20.                                 {
  21.                                         document.ProdUpload.elements[a].focus();
  22.                                         return false;
  23.                                 }
  24.                         }
  25.                 }
  26.         }
  27.        
  28.         if (count=="0") //  count 应该是 integer?
  29.         {
  30.                 alert("there");
  31.                 return true;
  32.                 alert("hello");
  33.         }
  34. }

  35. function ProdCheck(str)
  36. {
  37.      count = 0;
  38.      if (str == "")
  39.      {
  40.          count = 1;
  41.          alert("lease enter Product Name")
  42.          document.ProdUpload.elements[a].focus();
  43.          return false;
  44.       }      
  45.      return true;

  46. }
复制代码


可以把FORM都UPLOAD上来看看吗?。
回复

使用道具 举报

晓思 该用户已被删除
 楼主| 发表于 12-7-2006 03:13 PM | 显示全部楼层
可以.....希望你能明白 谢谢........
<script language="JavaScript">
        function check()
        {
                for (var i = 1; i<document.ProdUpload.elements.length; i++)
        {
                        if ((document.ProdUpload.elements.type == "file")
                        {
                    count = 0;
                                a = i - 2;
                b = i - 1;
                ImageValue = document.ProdUpload.elements.value.length;
                       ProdName = document.ProdUpload.elements[a].value;
                       ProdDescp = document.ProdUpload.elements.value;

                       if ((ImageValue == 0))
                       {
                               count = 0;
                               alert("ic";
                       }
                       else
                       {
                          count = 1;
                   alert("no";
                       }
                }
               }

               if ((count == 1))
               {
                       alert("can";
                       return true;
               }
               alert("there";
               return true;
               alert("hello";
    }
</script>
<body>
<form name="rodUpload" enctype="multipart/form-data" method="post" action="rodUpload.php" onsubmit="return check();">
  <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_size; ?>">
  <?php
     if ($UserID <> "" and $UserType=="E"
     {
  ?>
        <table border="1">
        <tr>
             <td colspan="5"><?php echo $multi_upload->show_error_string(); ?></td>
        </tr>
        <?php
                $sql = "select UserType
                           from userpeaccount
                                   where UserID = '$UserID'";

                   $ResultStrSql = mysql_query($sql, $link);
                   $row = mysql_fetch_assoc($ResultStrSql);
                   $PEType = $row['UserType'];
        ?>
        <?php
            $i = 1;

            if ($PEType == 'M')
            {
                      $j = 15;
            }
            else
            {
                    $j = 5;
            }

            while ($i <= $j):
        ?>
        <tr><td colspan="5">roduct <?php echo $i;?> Upload</td></tr>
        <tr><td colspan="5" height=""></td></tr>
        <tr>
             <td>roduct Name</td>
             <td align="left"><input type="text" name="rodName<?php echo $i;?>"></td>
             <td></td>
             <td>Date</td>
             <td><?php echo date("d-m-Y"; ?></td>
        </tr>
        <tr>
             <td>roduct Description</td>
             <td colspan="4">&nbsp;&nbsp<textarea name="Descp<?php echo $i;?>" rows="5" cols="30"></textarea></td>
        </tr>
        <tr>
             <td><label for="upload[]">Image:</label></td>
             <td colspan="4" align="left"><input type="file" name="upload[]" size="30"></td>
        </tr>
        <tr><td colspan="5" height="15"></td></tr>
        <?php
            $i++;
            endwhile;
        ?>
        <tr>
             <td>Replace files?</td>
             <td colspan="4" align="left"><input type="checkbox" name="replace" value="y"></td>
        </tr>
        <tr>
             <td colspan="5" align="right"><input type="reset" name="reset" value="Reset"><input type="submit" name="Submit" value="Submit"></td>
        </tr>
  <?php
       }
       else
       {
            call_user_func('ErrPermission');
  ?>
  <?php
       }
  ?>
</form>
</table>
</body>
回复

使用道具 举报

发表于 12-7-2006 04:28 PM | 显示全部楼层
document.ProdUpload.elements 是 ARRAY 来的。。

document.ProdUpload.elements.type 应该写成 document.ProdUpload.elements.type。。。


document.ProdUpload.elements.value 也一样。
回复

使用道具 举报

Follow Us
发表于 12-7-2006 04:33 PM | 显示全部楼层
SORRY 误会。
我不懂原来
  1. [i]
复制代码

是SHOW没有动西的。。。
回复

使用道具 举报

晓思 该用户已被删除
 楼主| 发表于 12-7-2006 05:12 PM | 显示全部楼层
oh 不用紧.....有谁能帮到我吗?? return不能function leh
回复

使用道具 举报


ADVERTISEMENT

发表于 12-7-2006 05:34 PM | 显示全部楼层
你在按submit之后还是停留在同个page?
回复

使用道具 举报

晓思 该用户已被删除
 楼主| 发表于 12-7-2006 06:04 PM | 显示全部楼层
yes...如过我没有放nested if 我就可以另一个page....先在不能
回复

使用道具 举报

发表于 13-7-2006 02:45 PM | 显示全部楼层
试试看 onsubmit="return check(this);
回复

使用道具 举报

晓思 该用户已被删除
 楼主| 发表于 14-7-2006 09:25 AM | 显示全部楼层
谢谢.....你帮了我.....
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 23-9-2024 05:24 AM , Processed in 0.092956 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表