[JS + PHP]error

Pagina: 1
Acties:
  • 54 views sinds 30-01-2008

  • KoBolD54
  • Registratie: Maart 2002
  • Laatst online: 17:42
ik ben bezig met een validatie script in java voor mijn PHP site.

Het script heeft gewerkt en na mij weten heb ik niets veranderd maar op eens werkt het script niet meer.
hopelijk kunnen jullie mij helpen?
De pagina's worden include dus heb ik de body tags enzo weg gelaten.
Het path waar het javascript zich bevind klopt ook, ik had eerst ../scripts/validation.js maar het leek er op dat javascript geen onderliggende mappen kon bekijken ofzo en toen heb ik er maar gewoon, scripts/validation.js van gemaakt en toen werkte hij, maar nu niet meer.

PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<script language="javascript" src="scripts/validation.js"></script>

<form name="userinfo" method="get" onSubmit="return checkForm()">
<input type="hidden" name="page" value="order.php">

    <table class="main" width="725" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td class="table_top" colspan="2">Gelieve alle velden invullen.<br /><br /></td>
    </tr>
    <tr>
        <td width="110">Achternaam</td>
        <td width="615"><input class="button" name="achternaam" type="text" size="20" maxlength="20"></td>
    </tr>
    <tr>
        <td width="110">Voornaam</td>
        <td width="615"><input class="button" name="voornaam" type="text" size="20" maxlength="20"></td>
    </tr>
    <tr>
        <td width="110">Adres</td>
        <td width="615"><input class="button" name="adres" type="text" size="40" maxlength="40"></td>
    </tr>
    <tr>
        <td width="110">Postcode</td>
        <td width="615"><input class="button" name="postcode" type="text" size="8" maxlength="6"> 
        Bijvoorbeeld: 1234AB </td>
    </tr>
    <tr>
        <td width="110">Plaats</td>
        <td width="615"><input class="button" name="plaats" type="text" size="40" maxlength="40"></td>
    </tr>
    <tr>
        <td width="110">Land</td>
        <td width="615"><input class="button" name="land" type="text" size="40" maxlength="40"></td>
    </tr>
    <tr>
        <td width="110">Telefoonnummer</td>
        <td width="615"><input class="button" name="telefoonnummer" type="text" size="12" maxlength="10"> 
          Bijvoorbeeld: 0555432109 </td>
    </tr>
    <tr>
        <td width="110">E-mail adres</td>
        <td width="615"><input class="button" name="email" type="text" size="40" maxlength="40"></td>
    </tr>
</table>
<hr />
<table width="725" border="0" cellpadding="0" cellspacing="0">
    <tr class="table_top">
        <td width="91">Merk</td>
        <td width="221">Product</td>
        <td width="46">Inhoud</td>
        <td width="51">Prijs</td>
        <td width="150">Aantal</td>
        <td width="81">Subtotaal</td>
        <td width="85">&nbsp;</td>
    </tr>
</table>
<br />
<?php
foreach ($_SESSION['mandje'] as $productnummer => $aantal) {
    toevoegen_product($productnummer, $aantal);
}

// functie voor het weergeven van de producten
function toevoegen_product($functie_productnummer, $functie_aantal) {

    // database connectie maken
    include ('include/connectdb.inc.php');

    // gekozen producten weergeven
    $artikelen_sql = "SELECT * FROM artikelen WHERE ID =" . $functie_productnummer;
    $artikelen_result = mysql_query($artikelen_sql);
    while ($artikelen = mysql_fetch_array($artikelen_result)) {

?>

        <table width="725" border="0" cellpadding="0" cellspacing="0">
            <tr class="table_input">
                <td width="91"><?php echo $artikelen['merk']; ?></td>
                <td width="221"><?php echo $artikelen['product']; ?></td>
                <td width="46"><?php echo $artikelen['inhoud']; ?></td>
                <td width="51">&euro;&nbsp;<?php echo $artikelen['prijs']; ?></td>
                <td width="150"><input class="button" name="product_aantal[<?php echo $functie_productnummer; ?>]" type="text" value="<?php echo $functie_aantal; ?>" size="2" maxlength="3"></td>
                <td width="81">&euro;&nbsp;<?php $subtotaal = $artikelen['prijs'] * $functie_aantal; echo number_format($subtotaal, 2); ?></td>
                <td width="85">&nbsp;</td>
            </tr>
        </table>
        
        <?php
        
        global $totaal;
        $totaal = $totaal + $subtotaal +10;

    }
}

?>

<br />
<table class="main" width="650" border="0" cellpadding="0" cellspacing="0">
<tr>
    <td class="table_total" width="450"><b>Totalen</b><br /></td>
    <td class="table_total" width="200">&nbsp;</td>
  <tr>
    <td class="table_btw" width="450">Totaal order (ex. BTW)</td>
    <td class="table_btw" width="200"><?php $ex_btw = $totaal / 1.19; echo "&euro;&nbsp;" . number_format($ex_btw, 2);?></td>
  </tr>
    <tr>
        <td class="table_btw" width="450">BTW 19%<br /></td>
        <td class="table_btw" width="200" align="left" valign="top"><?php $btw = $totaal - $ex_btw; echo "&euro;&nbsp;" . number_format($btw, 2);?></td>
    </tr>
    <tr>
        <td class="table_btw" width="450">Verzend kosten</td>
        <td class="table_btw" width="200">&euro;&nbsp;10.00</td>
    </tr>
    <tr>
        <td class="table_total" width="450"><br /><u><b>Totaalprijs</b></u></td>
        <td class="table_total" width="200"><?php echo "<u><b>&euro;&nbsp;" . number_format($totaal, 2) . "</b></u>"; ?></td>
    </tr>
</tr>
</table>
<hr />
<table width="650" border="0" cellpadding="0" cellspacing="0">
<tr>
    <td width="325" align="center"><input class="button" type="reset" name="reset" value="wissen"></td>
    <td width="325" align="center"><input class="button" type="submit" name="submit" value="verzenden"></td>
</tr>
</table>
</form>


code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
function checkForm()
{
    var checkfields = new Array();
    var message = '' ;

    var pattern_email = /^[-._&0-9a-zA-Z]+[@][-._&0-9a-zA-Z]+[.][._0-9a-zA-Z]+[a-zA-Z]$/;
    var pattern_phone = /^\d{10}$/;
    /*Deze variabele is niet van toepassing hier
    var pattern_valid_chars = /\W{2-20}/;*/
    
    checkfields[0] = "achternaam";
    checkfields[1] = "voornaam";
    checkfields[2] = "adres";
    checkfields[3] = "postcode";
    checkfields[4] = "plaats";
    checkfields[5] = "land";
    checkfields[6] = "telefoonnummer";
    checkfields[7] = "email";
    
    for (i=0; i<checkfields.length; i++)
    {
        if (document.userinfo.elements[checkfields[i]].value =='')
        {
            if (message == '')
            {
                message = checkfields[i];
            }
            else
            {
                message += (', ' + checkfields[i]);
            }
        }
    }
    
    if (message == '')
    {
        with(document.userinfo)
        {

            if(pattern_email.exec(email.value) == null)
            {
                alert("Ongeldig e-mail adres");
                email.focus();
                return false;
            }
            
            if(pattern_phone.exec(telefoonnummer.value) == null)
            {
                alert("Ongeldig telefoonnummer");
                telefoonnummer.focus();
                return false;
            }
            
        }
        return true;
    }
    
    else
    {
        message = 'De volgende velden zijn niet ingevuld:\n' + message;
        alert (message);
        return false;
    }
}

  • NMe
  • Registratie: Februari 2004
  • Laatst online: 15-04 22:07

NMe

Quia Ego Sic Dico.

En nou mogen wij een kleine 200 regels code voor jou gaan debuggen? Dacht het niet hoor, debuggen mag je zelf doen. ;)

Breng je probleem terug naar een paar regels code, dan kun je die posten. Zie ook P&W FAQ - Leer **** debuggen!!, en als je toch bezig bent, lees dan ook even P&W FAQ - De "quickstart". Met deze topicstart kunnen we niets. Sowieso hoort Javascript bij de buren in Webdesign & Graphics, en voor zover ik uit je post op kan maken zit je probleem in Javascript.

'E's fighting in there!' he stuttered, grabbing the captain's arm.
'All by himself?' said the captain.
'No, with everyone!' shouted Nobby, hopping from one foot to the other.


Dit topic is gesloten.