PHP.EE FOORUM   
Nimi:   Pass:   Mäleta mind! 
   Teemad | php.ee esilehele | registreeri | Märgi kõik teemad loetuks | #php.ee Skype vestlus | RSS
UUS TEEMA  OTSI  Lehekülgi: 1
Veateade javascripti valideerimisel
Postitaja: joker 2007-06-23 11:35:12
Javascriptis validate funktsiooni käivitamisel annab veateate
Line: 23
Object: 6
Error: Object doesn't support this property of method

Mitte ei mõista, mis viga! Peaks ju kõik OK olema, kuid veateade vaatab ikka vastu. Oskab keegi aidata?

<html>
<head>
<script type="text/javascript">
var http = false;

if(navigator.appName == "Microsoft Internet Explorer") {
http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
http = new XMLHttpRequest();
}

function validate() {

for (var n = 0; n < 1; n++)
{

http.abort();
http.open("GET", "validate.php?name=" + document.getElementsByName('item_code[' + n + ']')[0].value, true);
http.onreadystatechange=function() {
if(http.readyState == 4) {
results = http.responseText.split(",");
document.getElementByName('title[' + n + ']')[0].value = results[0];
document.getElementByName('item_price[' + n + ']')[0].value = results[1];
}
}
http.send(null);
}
}
</script>
<style type="text/css">
#warn { color: #C20000; background: #FFC5A8 }
#notice { color: #248A01; background: #CCFFBC }
</style>
</head>
<body>

<h1>Please choose your username:</h1>

<form>
<table>
<tr>
<td>Tootekood<td>
<td>Toote nimetus<td>
<td>Hind<td>
</tr>
<tr>
<td><input type="text" size="8" name="item_code[0]" onkeyup="validate()" /><td>
<td><input type="text" size="25" name="title[0]" disabled="disabled" id="title[0]" /><td>
<td><input type="text" size="5" name="sell_price[0]" id="sell_price[0]" /><td>
</tr>
<tr>
<td><input type="text" size="8" name="item_code[1]" onkeyup="validate()" /><td>
<td><input type="text" size="25" name="title[1]" disabled="disabled" id="title[1]" /><td>
<td><input type="text" size="5" name="sell_price[1]" id="sell_price[1]" /><td>
</tr>
<table>


</form>

</body>
</html>


"
RE: Veateade javascripti valideerimisel
Postitaja: joker 2007-06-23 15:29:58
Sain vist isegi järgnevalt tööle:

<html>
<head>
<script type="text/javascript">
var http = false;

if(navigator.appName == "Microsoft Internet Explorer") {
http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
http = new XMLHttpRequest();
}

function validate(field) {
//for (var n = 0; n < 2; n++)
//{
//if (document.getElementById('item_code['+n+']') != '') {
http.abort();
http.open("GET", "validate.php?name=" + document.getElementById('item_code['+field+']').value, true);
http.onreadystatechange=function() {
if(http.readyState == 4) {
results = http.responseText.split(",");
document.getElementById('title['+field+']').value = results[0];
document.getElementById('sell_price['+field+']').value = results[1];
}
}
http.send(null);
//}
//}
}
</script>
<style type="text/css">
#warn { color: #C20000; background: #FFC5A8 }
#notice { color: #248A01; background: #CCFFBC }
</style>
</head>
<body>

<h1>Please choose your username:</h1>

<form>
<table>
<tr>
<td>Tootekood<td>
<td>Toote nimetus<td>
<td>Hind<td>
</tr>
<tr>
<td><input type="text" size="8" name="item_code[0]" onkeyup="validate(0)" /><td>
<td><input type="text" size="25" name="title[0]" disabled="disabled" id="title[0]" /><td>
<td><input type="text" size="5" name="sell_price[0]" id="sell_price[0]" /><td>
</tr>
<tr>
<td><input type="text" size="8" name="item_code[1]" onkeyup="validate(1)" /><td>
<td><input type="text" size="25" name="title[1]" disabled="disabled" id="title[1]" /><td>
<td><input type="text" size="5" name="sell_price[1]" id="sell_price[1]" /><td>
</tr>
<table>


</form>

</body>
</html>



"
RE: Veateade javascripti valideerimisel
Postitaja: joker 2007-06-23 15:50:53
Täitsa absurd, nüüd IEga töötab kuid Mozillaga mitte.
RE: Veateade javascripti valideerimisel
Postitaja: joker 2007-06-23 16:43:14
Deem, näed suure vaeva ära, ning siis avastad, et script töötab ainult IE7ga.
RE: Veateade javascripti valideerimisel
Postitaja: muig 2007-06-24 14:26:59
TSITEERITUD:
Deem, näed suure vaeva ära, ning siis avastad, et script töötab ainult IE7ga.

Järelikult on veel arenguruumi :D
RE: Veateade javascripti valideerimisel
Postitaja: axelpaan_ 2007-06-24 14:27:12
vihjeks
...
document.getElementById('item_code_'+field).value, true);
...
<td><input type="text" size="8" id="item_code_0" name="item_code[0]" onkeyup="validate(0)" /><td>
RE: Veateade javascripti valideerimisel
Postitaja: joker 2007-06-24 16:19:57
Aitäh Axelplan, sa oled parim!
RE: Veateade javascripti valideerimisel
Postitaja: axelpaan_ 2007-06-25 01:04:16
TSITEERITUD:
Aitäh Axelpaan, sa oled parim!

oh sa meelitaja!

Leheküljed: 1

©2002-2013 Martin Rebane & PHP.ee kaasautorid
  0.0857269763947