hello everyone!!!
I am new to php and it seems I have alot of problems with my scripts.
I have this code:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>books</title>
<script language="javascript">
<!--
function addPrice(number,price){
var f=document.bookstore;
f.booksNo[number-1].disabled = false;
f.thisprice[number-1].value = price;
}
function removePrice(number,price){
var f=document.bookstore;
f.booksNo[number-1].disabled = true;
f.thisprice[number-1].value = "0";
}
function addbooksNo(number,price){
var f=document.bookstore;
var output = eval(price*((f.booksNo[number-1].selectedIndex)+1));
f.thisprice[number-1].value = output;
}
function TotalPrice(){
var f=document.bookstore;
output = "0";
for (i=0;i<f.thisprice.length;i++){
output=eval(output);
output+=eval(f.thisprice.value);
}
f.total.value=[output];
}
//-->
</SCRIPT>
</head>
<body>
<FORM METHOD=post ACTION="files/check.php3" name="bookstore" onsubmit="return check()" onclick="TotalPrice();">
<table><tr >
<td>Book1<hr></td>
<td><INPUT type ="checkbox" id="unchecked" NAME="chkbox[]" value="name of book 1" onclick="if (this.checked) addPrice(1,10);else removePrice(1,10);">
</td><td>
<select size="1" name="booksNo" type="select" id="unselectbox" disabled onchange="addbooksNo(1,10)">
<option value="1 book">1</option>
<option value="2 books">2</option>
<option value="3 books">3</option>
</select></td>
<input type="hidden" value="0" name="thisprice" id="thisprice">
</tr><tr>
<td>Book2<hr></td>
<td><INPUT type ="checkbox" id="unchecked" NAME="chkbox[]" value="name of book 2" onclick="if (this.checked) addPrice(2,20);else removePrice(2,20);">
</td><td>
<select size="1" name="booksNo" type="select" id="unselectbox" disabled onchange="addbooksNo(2,20)">
<option value="1 book">1</option>
<option value="2 books">2</option>
<option value="3 books">3</option>
</select></td>
<input type="hidden" value="0" name="thisprice" id="thisprice">
</tr><tr>
<td>Book3<hr></td>
<td><INPUT type ="checkbox" id="unchecked" NAME="chkbox[]" value="name of book 3" onclick="if (this.checked) addPrice(3,30);else removePrice(3,30);">
</td><td>
<select size="1" name="booksNo" type="select" id="unselectbox" disabled onchange="addbooksNo(3,30)">
<option value="1 book">1</option>
<option value="2 books">2</option>
<option value="3 books">3</option>
</select></td>
<input type="hidden" value="0" name="thisprice" id="thisprice">
</tr></table>
<table bgcolor="#CCE1F0"><tr>
<td>price:</td><td>
<input type="text" name="total" value="0"></td>
</tr></table>
<INPUT TYPE="submit" value="Send"><p>
</FORM></body>
This is a part of a form. This form is later on manipulated by a php script. Unfortunatelly I cannot use this javascript cause I have to add [] at the end of the names so php to get them. I am trying one week now to make this html page, a php page. The problem is I cannot make a php script to work exaclty as my javascript script.
Can Anyone please help me?
How can I have a php script at the same page? Can I make a php script to work just like the javasctipt scripts above?
As you can see my only "NAME" problem is for "booksNo". I want php to take chkbox[] (which I can do), total (which i also have no problem) and booksNo which is my real problem
Thank you all