Forum Moderators: coopster

Message Too Old, No Replies

drop down menu syntax question

         

RogueDogg

10:04 pm on Jul 3, 2006 (gmt 0)

10+ Year Member



Here is my code:

echo "<option value = '".$record["Price"]."'>".$record["ProductName"]."\n";

Is it possible to do a wildcard character as follows:

echo "<option value = '".$record["%"]."'>".$record["ProductName"]."\n";

So instead of only haveing Price ( not a wildcard) and ProductName, it will be anything + ProductName? Am I explaining this correctly?

possibly: echo "<option value = '".$record["%ANY_RECORD_NAME"]."'>".$record["ProductName"]."\n";

RogueDogg

10:39 pm on Jul 3, 2006 (gmt 0)

10+ Year Member



In addition to my first post:

So instead of only haveing Price ( not a wildcard) and ProductName, it will be anything + ProductName? Am I explaining this correctly?

possibly: echo "<option value = '".$record["%ANY_RECORD_NAME"]."'>".$record["ProductName"]."\n";

The big problem I'm having is I have a java script that is taking these values and displaying them where I specify, but I've only been able to get it work with 2 variables at once, I need 3 or more. Meaning if I choose a ProductName from the drop downlist, and want to display the Price, I would also like to be able to display the ProductDescription as well, but I am only able again to get 2 to display at once, meaning I can get ProductName and Price or ProductName and ProductDescription, NOT ProductName, Price, AND ProductDescription. ARGH I sure hope I'm explaining myself good enough.

Sekka

8:34 am on Jul 4, 2006 (gmt 0)

10+ Year Member



I think I understand what you are trying to achieve.

You want to store all the values from the row in the value part of the option?

If this is the case, may I ask why?

RogueDogg

5:33 pm on Jul 4, 2006 (gmt 0)

10+ Year Member



Yes that is correct, But it seems in conjunction with the script I'm using if I don't store the values it can't retrieve them, therefore cannot display them when I request to them to be displayed. I have tested this by changing the "ProductDesc" to another row such as "Price" and then it would display the price instead of the "ProductDesc". Now I've tried using the "%" and it didn't work, nothing would display, so there goes that theroy. I've also tried adding another row in there such as
<option value='".$row["ProductDesc"]."','".$row["Price"]."'>'".$row["Product"]."'
and that didn't work either. I'm still stuck on this, unless I'm going about this all wrong?

Sekka

11:26 pm on Jul 4, 2006 (gmt 0)

10+ Year Member



Personally I would advise against this approach. Either refresh the page or use Ajax to load your list.

If you really want to do it that way, store all the variables in the value field using "¦" as a seperator and then when JS gets this string from the value field, use it as a needle to split the string into an array. This is in theory as I have never done this before.

Another approach could be to hide the information you need in hidden form fields.

Hope this helps.

RogueDogg

3:01 am on Jul 5, 2006 (gmt 0)

10+ Year Member



With the help from another forum we were able to figure it out. Thank you for your help anyways, you were on the right path with the "¦" and spliting up the array, that's basically what we had to do and a few other modifications but it works well. If anyone would like me to post the code just ask and I will. Thanks again.