adi123 Posted February 18, 2012 Share Posted February 18, 2012 I am trying to display another list menu when "Ready Made" is selected from prod_type through an if statement but nothing happens. I don't know what the error is, can some one help please. <select name="prod_type" id="prod_type" style="padding:5px;"> <option>Select Product Type</option> <option>Ready Made</option> <option>Unstiched</option> </select> <?php if ($prod_type == 'Ready Made') { echo "<p>Size:</p>\n"; echo " <p>\n"; echo " <label>\n"; echo " <select name=\"prod_size\" id=\"prod_size\" style=\"padding:5px;\">\n"; echo " <option selected=\"selected\">Select Size</option>\n"; echo " <option>32</option>\n"; echo " <option>34</option>\n"; echo " <option>36</option>\n"; echo " <option>38</option>\n"; echo " <option>40</option>\n"; echo " <option>42</option>\n"; echo " <option>44</option>\n"; echo " <option>46</option>\n"; echo " <option>48</option>\n"; echo " <option>50</option>\n"; echo " <option>52</option>\n"; echo " <option>54</option>\n"; echo " <option>56</option>\n"; echo " <option>58</option>\n"; echo " <option>60</option>\n"; echo " </select>\n"; echo " </label>\n"; echo " <a href=\"#\" class=\"style7\">Check Size Chart </a></p>\n"; } else { echo ""; } ?> Link to comment https://forums.phpfreaks.com/topic/257243-php-if-statement/ Share on other sites More sharing options...
smerny Posted February 18, 2012 Share Posted February 18, 2012 are you expecting something to happen after the user changes the select/option without loading a page? php is server side code and cannot run on the client side. Link to comment https://forums.phpfreaks.com/topic/257243-php-if-statement/#findComment-1318604 Share on other sites More sharing options...
adi123 Posted February 18, 2012 Author Share Posted February 18, 2012 I would like the page to echo without reloading, if its possible. Its part of a form when the user clicks an option another list menu appears below Link to comment https://forums.phpfreaks.com/topic/257243-php-if-statement/#findComment-1318618 Share on other sites More sharing options...
smerny Posted February 19, 2012 Share Posted February 19, 2012 you're just wanting a new select option to show up right? use JavaScript.. try this <script type="text/javascript"> var ele = document.getElementById("prod_type"); var selected= ele.options[ele.selectedIndex].text; if(selected == "Ready Made"){ document.getElementById('readyMadeSelect').innerHTML = "All the stuff you were trying to echo goes here"; } <script> <select name="prod_type" id="prod_type" style="padding:5px;" onchange="updateReadyMade()"> <option>Select Product Type</option> <option>Ready Made</option> <option>Unstiched</option> </select> <div id="readyMadeSelect"></div> Link to comment https://forums.phpfreaks.com/topic/257243-php-if-statement/#findComment-1318772 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.