|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||||
|
|||||
|
string variable not working
hi!
need help to resolve this... i'm doing a popup menu in javascript and php. i noticed that if i do a php Code:
then the x is added to the menu, but everytime i do then nothing happens. returns a value of 'computer', though. note that 'category' is a class object. any idea here? thanks! |
|
#2
|
|||
|
|||
|
RE: string variable not working
Like in PHP strings should be enclosed between quotes:
<script type="text/javascript" language="Javascript"> x = '<?php echo $row['prod_category'] ?>'; category.addMenuItem(x); </script> |
|
#3
|
|||
|
|||
|
RE: string variable not working
thanks crisp!
by the way, sorry for not emphasizing this in my previous post but doing a x = 'computer' doesn't work either so it seems that assigning the variable x with a string value causes the object category not to accept x. and perhaps javascript treats <?php echo $row['prod_category'] ?> as string. this is what i actually mean in this post's title... |
|
#4
|
|||
|
|||
|
RE: string variable not working
javascript will only treat a value as string when it is enclosed in quotes. Else it will treat it as a number or an object reference.
The fact that you write your script with PHP shouldn't matter, what matters is what is sent to the browser, which you can easily see by using view-source in your browserscreen. Could you post some more of this script? I would assume that you need to sent a string to your addMenuItem method.. |
|
#5
|
|||||
|
|||||
|
RE: string variable not working
here's the code. it's a bit long:
php Code:
i manually coded the the script then use the data from dbase and it ran properly. i just notice that doing a category.addMenuItem(prod1); works fine but category.addMenuItem("prod1"); didn't. |
|
#6
|
|||
|
|||
|
RE: string variable not working
try changing
var i = '<?php echo $rowCategory[1] ?>'; category.addMenuItem(i); into category.addMenuItem(<?php echo $rowCategory[1] ?>); |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > string variable not working |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|