Forum Moderators: open
// Courtesy of SimplytheBest.net - http://simplythebest.net/scripts/
<!--
function showDescription(whatForm){
if(document.forms[whatForm].product.value=="none"){
document.forms[whatForm].productdesc.value="product description"
}else{
document.forms[whatForm].productdesc.value=document.forms[whatForm].product.value
}}
// -->
</script> So basically this will allow someone to create a drop down menu and populate it however they wish, in my case a db query and when the "product" is selected it will display the "product description" where ever I chose, in my case a textarea. My question is how can I add to this? Meaning if I wanted to also display the price for the product selected along with the description, how can I include the price variabe in this? I will put the price in a textarea as well. Make sense? I've tried modifying the script using what has been given to me but I cannot seem to make it work right, any changes I make seem to mess the script up and then it doesn't work.
document.forms[whatForm].productdesc.value=document.forms[whatForm].product.value
var msg=document.forms[whatForm].product.value +
"\n Now only " + price;
document.forms[whatForm].productdesc.value=msg;
(Note within the value of a textarea the \n means newline)
Price is not defined on line 24
Here is line 24:
"\n Now only " + price; This is what I've been able to come up with and what is happening is when I chose a product from the drop down list it displays the productdescritpion in both the text area ( which is what I want ) and in the text box ( which should be the price ). Now that I'm able to get both areas populated with information now it's just a matter of getting the information in the script in the correct order? You think?
<SCRIPT LANGUAGE="JavaScript">
function showDescription(whatForm){
if(document.forms[whatForm].product.value=="ProductName"){
document.forms[whatForm].productdesc.value=="ProductDesc"
document.forms[whatForm].price.value=="Price"
}else{
var msg=document.forms[whatForm].price.value=document.forms[whatForm].product.value;
document.forms[whatForm].productdesc.value=msg;
}}
</script>
echo "<option value = '".$record["ProductDesc"]."'>".$record["ProductName"]."\n"; That alone only allows me to display the ProductName ( drop down menu ) and ProductDescription ( text area or where I ever I want ). So what I need to do now is somehow get it to recognize all or atleast one more field ( Price ). Make any sense?