retrive and display
Moderator: General Moderators
retrive and display
Hello,
I have a combo box (drop down). i am retriving various sizes from database and displaying in that.
In another field of that table has its corresponding price for it. if i change the sizes, the corresponding price for each sizes should display, without the form being submitted. (Without using ajax).
Thanx
I have a combo box (drop down). i am retriving various sizes from database and displaying in that.
In another field of that table has its corresponding price for it. if i change the sizes, the corresponding price for each sizes should display, without the form being submitted. (Without using ajax).
Thanx
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: retrive and display
you need a Array of Javascriptkpraman wrote:Hello,
I have a combo box (drop down). i am retriving various sizes from database and displaying in that.
In another field of that table has its corresponding price for it. if i change the sizes, the corresponding price for each sizes should display, without the form being submitted. (Without using ajax).
Thanx
You should reading all price to the array.
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Call a function, onChange, to determine which size was chosen, and depending on which size was chosen, alter something whether it be a textbox, or a div containing text/form input
Pseudo-code:
Of course, for it to be cross browser you may have to mess with some things, but this is nothing you can't learn easily
Pseudo-code:
Code: Select all
function showPrice(formHandle, objectHandle){
if(document.forms[formHandle].objectHandle.option[i] == "whatever")
someDiv.innerHTML = "such and such";
}Thanx for your replies.
I retrive the values of sizes and prices and combine them
then, in the form
in javascript
I retrive the values of sizes and prices and combine them
Code: Select all
$query_size=mysql_query("SELECT * FROM product_details,product_sizes WHERE product_details.productId=$productId AND product_sizes.sizeId=product_details.size");
while($size=mysql_fetch_array($query_size))
{
$sizearr[]=$size['sizeId'];
$price[]=$size['price'];
$dropsize.="<option value=$size[sizeId] onChange=\"call('$size[sizeId]')\">$size[sizeName]</option>";
}
$merge=array_combine($sizearr,$price);Code: Select all
<td><select name=sizeId onChange=\"call('$size[sizeId]',$merge)\">$dropsize</select></td>Code: Select all
function call(size,merge)
{
alert(merge[size]);// i am not able to get values
}
I am new to js. is it the correct way of passing values?