Skip to main content

Dynamic Dropdown Menu if-else does not become dynamic



I have two dropdown menus, im having trouble with making the options for the second dropwdown to be dependent on the choice on the first dropdown menu.







$city="";

$formcontent =<<<EOT

<label>Assumed Bitten City : </label>

<select name="AssumedBittenCity" id="AssumedBittenCity">

<option value="0">Make a Selection</option>

<option value="Caloocan City">Caloocan City</option>

<option value="Las Pi&#241;as City">Las Pi&#241;as City</option>

<option value="Makati City">Makati City</option>

<option value="Malabon City">Malabon City</option>

<option value="Mandaluyong City">Mandaulyong City</option>

<option value="Manila City">Manila City</option>

<option value="Marikina City">Marikina City</option>

<option value="Muntinlupa City">Muntinlupa City</option>

<option value="Navotas City">Navotas City</option>

<option value="Para&#241;aque City">Para&#241;aque City</option>

<option value="Pasay City">Pasay City</option>

<option value="Pasig City">Pasig City</option>

<option value="Pateros City">Pateros City</option>

<option value="Quezon City" $city="Quezon City">Quezon City</option>

<option value="San Juan City">San Juan City</option>

<option value="Taguig City">Taguig City</option>

<option value="Valenzuela City">Valenzuela City</option>

</select><br></br>



<label>Assumed Bitten Street : </label>

<Select name="AssumedBittenStreet" id="AssumedBittenStreet">

<option value="0">Make a Selection</option>

EOT;



if($city="Quezon City"){





$formcontent.=<<<EOT



<option value="Kamuning Road">Kamuning Road</option>

<option value="K-1st Street">K-1st Street</option>

<option value="K-2nd Street">K-2nd Street</option>

<option value="K-3rd Street">K-3rd Street</option>

<option value="K-4th Street">K-4th Street</option>

<option value="K-5th Street">K-5th Street</option>

<option value="K-6th Street">K-6th Street</option>

<option value="K-7th Street">K-7th Street</option>

<option value="K-8th Street">K-8th Street</option>

<option value="K-D Street">K-D Street</option>

<option value="K-F Street">K-F Street</option>

<option value="K-Eth Street">K-Eth Street</option>

<option value="Eulogio Rodriguez Sr. Avenue">Eulogio Rodriguez Sr. Avenue</option>

<option value="Balete Drive">Balete Drive</option>

<option value="Park Ave">Park Ave</option>

<option value="L. Sianghio Street">L. Sianghio Street</option>

<option value="Teodoro Gener Street">Teodoro Gener Street</option>

<option value="Judge Damien Jimenez Street">Judege Damien Jimenez Street</option>

<option value="Scout Castor Street">Scout Castor Street</option>

<option value="Scout Lozano Street">Scout Lozano Street</option>

<option value="Scout Dr. Lazcano Street">Scout Lazcano Street</option>

<option value="Scout De Guia Street">Scout De Guia Street</option>

<option value="Scout Torillo Street">Scout Torillo Street</option>

<option value="Scout Ybardolaza Street">Scout Ybardolaza Street</option>

<option value="Scout Gandia Street">Scout Gandia Street</option>

<option value="Scout FuentebellaStreet">Scout Castor Street</option>

<option value="Scout Fernandez Street">Scout Fernandez Street</option>

<option value="Scout Limbaga Street">Scout Limbaga Street</option>

<option value="Scout Rallos Street">Scout Rallos Street</option>

<option value="Scout Tuason Street">Scout Tuason Street</option>

<option value="Scout Tobias Street">Scout Tobias Street</option>

<option value="Scout Santiago Street">Scout Santiago Street</option>

<option value="Scout Reyes Street">Scout Reyes Street</option>

<option value="Scout Magbanua Street">Scout Magbanua Street</option>

<option value="Scout Ojeda Street">Scout Ojeda Street</option>

<option value="Scout Chuatoco Street">Scout Chuatoco Street</option>

EOT;







currently this does not work, and I have no knowledge on javascript. What basic/simple solution can I do with this?


Comments

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.