Jump to content

php if statement


adi123

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.