簡體   English   中英

PHP和javascript在Internet Explorer和Google Chrome上正常運行,但在Samsung Galaxy Android上運行不正常

[英]PHP and javascript working correctly on Internet Explorer and Google Chrome but not on Samsung Galaxy Android

我有一個基於PHP的Web應用程序,在用戶輸入值時,它從mysql數據庫中提取詳細信息並顯示它而不刷新頁面。 這顯然是用javascript完成的。

這在移動設備(如黑莓和平板電腦)上正確地在Internet Explorer,Chrome等上正常工作,一旦用戶輸入數據,格式化就會搞砸。 看下面的屏幕截圖。

Internet Explorer,表結構仍然存在: 在此輸入圖像描述

移動設備(Galaxy Tablet),表結構改變了: 在此輸入圖像描述

例子可以在這里查看

涉及的2頁的代碼如下所示。 前端是一個php頁面,它使用javascript從mysql中獲取和顯示數據。

php頁面:

<html>
<head>
<title>test</title>
<script type="text/javascript"> 
  function showUser(userNumber, str) 
  { 
  document.getElementById("r"+(userNumber)).style.display="block";  
    if (str=="") 
    { 
      document.getElementById("txtHint1").innerHTML=""; 
      return; 
    }   
    if (window.XMLHttpRequest) 
    {// code for IE7+, Firefox, Chrome, Opera, Safari 
      xmlhttp=new XMLHttpRequest(); 
    } 
    else 
    {// code for IE6, IE5 
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
    } 

    xmlhttp.onreadystatechange=function() 
    { 
      if (xmlhttp.readyState==4 && xmlhttp.status==200) 
      { 
        document.getElementById("txtHint1").innerHTML=xmlhttp.responseText; 
      } 
    } 
    xmlhttp.open("GET","getdata1.php?q="+str,true); 
    xmlhttp.send(); 
  } 
</script> 
</head>
<body>

<form name="orderform" id="orderform" action="newsale.php" method="post">

<div align="left" id="txtHint1">mysql data will be shown here</div>
<br>
<table border="1">

    <tr id="r1">  
        <td>
            <input size="8"  type="text" id="sku1" name="sku1" onchange="showUser(1, this.value)" >
        </td>
        <td>
            <input  type="text" id="qty1" name="qty1" size="3">
        </td>
    </tr>
    <tr id="r2">  
        <td>
            <input size="8"  type="text" id="sku2" name="sku2" onchange="showUser(1, this.value)" >
        </td>
        <td>
            <input  type="text" id="qty2" name="qty2" size="3" >
        </td>
    </tr>
</table>

</form>
</body>
</html>

getdata1.php頁面獲取mysql數據:

<?php
 $q=$_GET["q"];

$con = mysql_connect('localhost', 'user', 'pass');
 if (!$con)
   {
   die('Could not connect: ' . mysql_error());
   }

mysql_select_db("database", $con);

$sql="SELECT Category, Description,SellingUnits,Grouping,CasesPerPallet,ShrinksPerPallet FROM skudata WHERE packcode = '".$q."'";

$result = mysql_query($sql);


while($row = mysql_fetch_array($result))
   {
   echo "<font color=blue size=2>Description:</font> <font color=red size=2>".$row['Description']."</font>, ";
   }

mysql_close($con);
 ?> 

再次感謝所有的幫助,我們對此表示贊賞。

或者,有沒有人有另外的JavaScript他們可以給我顯示mysql的數據? 道歉,但我的javascript技能是不存在的。

謝謝並恭祝安康,

問題出在JavaScript的第一行:

document.getElementById("r"+(userNumber)).style.display="block";

您要將第一個表行的顯示樣式設置為block 在你的情況下,我認為沒有理由這樣做,所以只需刪除該行,你的HTML就可以在所有瀏覽器中很好地工作,包括三星Galaxy Tab(我在實際平板電腦上測試過)。

作為旁注,細胞移位效應也發生在FireFox中(現在不再發生)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM