I have a user drop down menu in my form code where user can select their option to process their request. The div ids ranges from fa1 to fa8.By default I am showing fa1 and fa2 in my form and fa3 to fa8 are set to display: none. I have added a button to add remove additional drop down menu depends upon user requirement( which will display\hide fa3 to fa8)
I am able to keep the user selected options after form submit using
<option <?php if ($_POST['fa-select-1']==1) {echo "selected='selected'"; } ?> >1</option>
The issue I am facing here is if user added a addiotnal div (say fa3), selected drop down option and submit the form, the hidden div not displaying after submit (eventhough it keeping its drop down as user selected)
I would like to show the hidden div(if user added) as well along with the selected option after form submit
My html code:
<div class="block-no-height">
<div class="sub_headings"> Select Your FA director and Port</div>
<div class="wrap-quest-resp" id="fa1">
<div class="input-quest-no-height">FA and port - 1</div>
<div class="input-resp-no-height">
<select id="fa-select-1" name="fa-select-1">
<option disabled="disabled" SELECTED >Dir</option>
<option <?php if ($_POST['fa-select-1']==1) {echo "selected='selected'"; } ?> >1</option>
<option <?php if ($_POST['fa-select-1']==2) {echo "selected='selected'"; } ?> >2</option>
<option <?php if ($_POST['fa-select-1']==3) {echo "selected='selected'"; } ?> >3</option>
<option <?php if ($_POST['fa-select-1']==4) {echo "selected='selected'"; } ?> >4</option>
<option <?php if ($_POST['fa-select-1']==5) {echo "selected='selected'"; } ?> >5</option>
<option <?php if ($_POST['fa-select-1']==6) {echo "selected='selected'"; } ?> >6</option>
<option <?php if ($_POST['fa-select-1']==7) {echo "selected='selected'"; } ?> >7</option>
<option <?php if ($_POST['fa-select-1']==8) {echo "selected='selected'"; } ?> >8</option>
<option <?php if ($_POST['fa-select-1']==9) {echo "selected='selected'"; } ?> >9</option>
<option <?php if ($_POST['fa-select-1']==10) {echo "selected='selected'"; } ?> >10</option>
<option <?php if ($_POST['fa-select-1']==11) {echo "selected='selected'"; } ?> >11</option>
<option <?php if ($_POST['fa-select-1']==12) {echo "selected='selected'"; } ?> >12</option>
<option <?php if ($_POST['fa-select-1']==13) {echo "selected='selected'"; } ?> >13</option>
<option <?php if ($_POST['fa-select-1']==14) {echo "selected='selected'"; } ?> >14</option>
<option <?php if ($_POST['fa-select-1']==15) {echo "selected='selected'"; } ?> >15</option>
<option <?php if ($_POST['fa-select-1']==16) {echo "selected='selected'"; } ?> >16</option>
</select>
<select id="proc-select-1" name="proc-select-1">
<option disabled="disabled" SELECTED >Proc</option>
<option <?php if ($_POST['proc-select-1']==a) {echo "selected='selected'"; } ?> >a</option>
<option <?php if ($_POST['proc-select-1']==b) {echo "selected='selected'"; } ?> >b</option>
<option <?php if ($_POST['proc-select-1']==c) {echo "selected='selected'"; } ?> >c</option>
<option <?php if ($_POST['proc-select-1']==d) {echo "selected='selected'"; } ?> >d</option>
</select>
<select id="port-select-1" name="port-select-1">
<option disabled="disabled" SELECTED >Port</option>
<option <?php if ($_POST['port-select-1']==0) {echo "selected='selected'"; } ?> >0</option>
<option <?php if ($_POST['port-select-1']==1) {echo "selected='selected'"; } ?> >1</option>
</select>
</div>
</div>
<div class="wrap-quest-resp" id="fa2">
<div class="input-quest-no-height">FA and port - 2</div>
<div class="input-resp-no-height">
<select id="fa-select-2" name="fa-select-2">
<option disabled="disabled" SELECTED >Dir</option>
<option <?php if ($_POST['fa-select-2']==1) {echo "selected='selected'"; } ?> >1</option>
<option <?php if ($_POST['fa-select-2']==2) {echo "selected='selected'"; } ?> >2</option>
<option <?php if ($_POST['fa-select-2']==3) {echo "selected='selected'"; } ?> >3</option>
<option <?php if ($_POST['fa-select-2']==4) {echo "selected='selected'"; } ?> >4</option>
<option <?php if ($_POST['fa-select-2']==5) {echo "selected='selected'"; } ?> >5</option>
<option <?php if ($_POST['fa-select-2']==6) {echo "selected='selected'"; } ?> >6</option>
<option <?php if ($_POST['fa-select-2']==7) {echo "selected='selected'"; } ?> >7</option>
<option <?php if ($_POST['fa-select-2']==8) {echo "selected='selected'"; } ?> >8</option>
<option <?php if ($_POST['fa-select-2']==9) {echo "selected='selected'"; } ?> >9</option>
<option <?php if ($_POST['fa-select-2']==10) {echo "selected='selected'"; } ?> >10</option>
<option <?php if ($_POST['fa-select-2']==11) {echo "selected='selected'"; } ?> >11</option>
<option <?php if ($_POST['fa-select-2']==12) {echo "selected='selected'"; } ?> >12</option>
<option <?php if ($_POST['fa-select-2']==13) {echo "selected='selected'"; } ?> >13</option>
<option <?php if ($_POST['fa-select-2']==14) {echo "selected='selected'"; } ?> >14</option>
<option <?php if ($_POST['fa-select-2']==15) {echo "selected='selected'"; } ?> >15</option>
<option <?php if ($_POST['fa-select-2']==16) {echo "selected='selected'"; } ?> >16</option>
</select>
<select id="proc-select-2" name="proc-select-2">
<option disabled="disabled" SELECTED >Proc</option>
<option <?php if ($_POST['proc-select-2']==a) {echo "selected='selected'"; } ?> >a</option>
<option <?php if ($_POST['proc-select-2']==b) {echo "selected='selected'"; } ?> >b</option>
<option <?php if ($_POST['proc-select-2']==c) {echo "selected='selected'"; } ?> >c</option>
<option <?php if ($_POST['proc-select-2']==d) {echo "selected='selected'"; } ?> >d</option>
</select>
<select id="port-select-2" name="port-select-2">
<option disabled="disabled" SELECTED >Port</option>
<option <?php if ($_POST['port-select-2']==0) {echo "selected='selected'"; } ?> >0</option>
<option <?php if ($_POST['port-select-2']==1) {echo "selected='selected'"; } ?> >1</option>
</select>
</div>
</div>
<div class="wrap-quest-resp" id="fa3" style="display:none;" disabled="true">
<div class="input-quest-no-height">FA and port - 3</div>
<div class="input-resp-no-height">
<select id="fa-select-3" name="fa-select-3">
<option disabled="disabled" SELECTED >Dir</option>
<option <?php if ($_POST['fa-select-3']==1) {echo "selected='selected'"; } ?> >1</option>
<option <?php if ($_POST['fa-select-3']==2) {echo "selected='selected'"; } ?> >2</option>
<option <?php if ($_POST['fa-select-3']==3) {echo "selected='selected'"; } ?> >3</option>
<option <?php if ($_POST['fa-select-3']==4) {echo "selected='selected'"; } ?> >4</option>
<option <?php if ($_POST['fa-select-3']==5) {echo "selected='selected'"; } ?> >5</option>
<option <?php if ($_POST['fa-select-3']==6) {echo "selected='selected'"; } ?> >6</option>
<option <?php if ($_POST['fa-select-3']==7) {echo "selected='selected'"; } ?> >7</option>
<option <?php if ($_POST['fa-select-3']==8) {echo "selected='selected'"; } ?> >8</option>
<option <?php if ($_POST['fa-select-3']==9) {echo "selected='selected'"; } ?> >9</option>
<option <?php if ($_POST['fa-select-3']==10) {echo "selected='selected'"; } ?> >10</option>
<option <?php if ($_POST['fa-select-3']==11) {echo "selected='selected'"; } ?> >11</option>
<option <?php if ($_POST['fa-select-3']==12) {echo "selected='selected'"; } ?> >12</option>
<option <?php if ($_POST['fa-select-3']==13) {echo "selected='selected'"; } ?> >13</option>
<option <?php if ($_POST['fa-select-3']==14) {echo "selected='selected'"; } ?> >14</option>
<option <?php if ($_POST['fa-select-3']==15) {echo "selected='selected'"; } ?> >15</option>
<option <?php if ($_POST['fa-select-3']==16) {echo "selected='selected'"; } ?> >16</option>
</select>
<select id="proc-select-3" name="proc-select-3">
<option disabled="disabled" SELECTED >Proc</option>
<option <?php if ($_POST['proc-select-3']==a) {echo "selected='selected'"; } ?> >a</option>
<option <?php if ($_POST['proc-select-3']==b) {echo "selected='selected'"; } ?> >b</option>
<option <?php if ($_POST['proc-select-3']==c) {echo "selected='selected'"; } ?> >c</option>
<option <?php if ($_POST['proc-select-3']==d) {echo "selected='selected'"; } ?> >d</option>
</select>
<select id="port-select-3" name="port-select-3">
<option disabled="disabled" SELECTED >Port</option>
<option <?php if ($_POST['port-select-3']==0) {echo "selected='selected'"; } ?> >0</option>
<option <?php if ($_POST['port-select-3']==1) {echo "selected='selected'"; } ?> >1</option>
</select>
</div>
</div>
<div class="wrap-quest-resp" id="fa4" style="display:none;" >
<div class="input-quest-no-height">FA and port - 4</div>
<div class="input-resp-no-height">
<select id="fa-select-4" name="fa-select-4">
<option disabled="disabled" SELECTED >Dir</option>
<option <?php if ($_POST['fa-select-4']==1) {echo "selected='selected'"; } ?> >1</option>
<option <?php if ($_POST['fa-select-4']==2) {echo "selected='selected'"; } ?> >2</option>
<option <?php if ($_POST['fa-select-4']==3) {echo "selected='selected'"; } ?> >3</option>
<option <?php if ($_POST['fa-select-4']==4) {echo "selected='selected'"; } ?> >4</option>
<option <?php if ($_POST['fa-select-4']==5) {echo "selected='selected'"; } ?> >5</option>
<option <?php if ($_POST['fa-select-4']==6) {echo "selected='selected'"; } ?> >6</option>
<option <?php if ($_POST['fa-select-4']==7) {echo "selected='selected'"; } ?> >7</option>
<option <?php if ($_POST['fa-select-4']==8) {echo "selected='selected'"; } ?> >8</option>
<option <?php if ($_POST['fa-select-4']==9) {echo "selected='selected'"; } ?> >9</option>
<option <?php if ($_POST['fa-select-4']==10) {echo "selected='selected'"; } ?> >10</option>
<option <?php if ($_POST['fa-select-4']==11) {echo "selected='selected'"; } ?> >11</option>
<option <?php if ($_POST['fa-select-4']==12) {echo "selected='selected'"; } ?> >12</option>
<option <?php if ($_POST['fa-select-4']==13) {echo "selected='selected'"; } ?> >13</option>
<option <?php if ($_POST['fa-select-4']==14) {echo "selected='selected'"; } ?> >14</option>
<option <?php if ($_POST['fa-select-4']==15) {echo "selected='selected'"; } ?> >15</option>
<option <?php if ($_POST['fa-select-4']==16) {echo "selected='selected'"; } ?> >16</option>
</select>
<select id="proc-select-4" name="proc-select-4">
<option disabled="disabled" SELECTED >Proc</option>
<option <?php if ($_POST['proc-select-4']==a) {echo "selected='selected'"; } ?> >a</option>
<option <?php if ($_POST['proc-select-4']==b) {echo "selected='selected'"; } ?> >b</option>
<option <?php if ($_POST['proc-select-4']==c) {echo "selected='selected'"; } ?> >c</option>
<option <?php if ($_POST['proc-select-4']==d) {echo "selected='selected'"; } ?> >d</option>
</select>
<select id="port-select-4" name="port-select-4">
<option disabled="disabled" SELECTED >Port</option>
<option <?php if ($_POST['port-select-4']==0) {echo "selected='selected'"; } ?> >0</option>
<option <?php if ($_POST['port-select-4']==1) {echo "selected='selected'"; } ?> >1</option>
</select>
</div>
</div>
<div class="wrap-quest-resp" id="fa5" style="display:none;" >
<div class="input-quest-no-height">FA and port - 5</div>
<div class="input-resp-no-height">
<select id="fa-select-5" name="fa-select-5">
<option disabled="disabled" SELECTED >Dir</option>
<option <?php if ($_POST['fa-select-5']==1) {echo "selected='selected'"; } ?> >1</option>
<option <?php if ($_POST['fa-select-5']==2) {echo "selected='selected'"; } ?> >2</option>
<option <?php if ($_POST['fa-select-5']==3) {echo "selected='selected'"; } ?> >3</option>
<option <?php if ($_POST['fa-select-5']==4) {echo "selected='selected'"; } ?> >4</option>
<option <?php if ($_POST['fa-select-5']==5) {echo "selected='selected'"; } ?> >5</option>
<option <?php if ($_POST['fa-select-5']==6) {echo "selected='selected'"; } ?> >6</option>
<option <?php if ($_POST['fa-select-5']==7) {echo "selected='selected'"; } ?> >7</option>
<option <?php if ($_POST['fa-select-5']==8) {echo "selected='selected'"; } ?> >8</option>
<option <?php if ($_POST['fa-select-5']==9) {echo "selected='selected'"; } ?> >9</option>
<option <?php if ($_POST['fa-select-5']==10) {echo "selected='selected'"; } ?> >10</option>
<option <?php if ($_POST['fa-select-5']==11) {echo "selected='selected'"; } ?> >11</option>
<option <?php if ($_POST['fa-select-5']==12) {echo "selected='selected'"; } ?> >12</option>
<option <?php if ($_POST['fa-select-5']==13) {echo "selected='selected'"; } ?> >13</option>
<option <?php if ($_POST['fa-select-5']==14) {echo "selected='selected'"; } ?> >14</option>
<option <?php if ($_POST['fa-select-5']==15) {echo "selected='selected'"; } ?> >15</option>
<option <?php if ($_POST['fa-select-5']==16) {echo "selected='selected'"; } ?> >16</option>
</select>
<select id="proc-select-5" name="proc-select-5">
<option disabled="disabled" SELECTED >Proc</option>
<option <?php if ($_POST['proc-select-5']==a) {echo "selected='selected'"; } ?> >a</option>
<option <?php if ($_POST['proc-select-5']==b) {echo "selected='selected'"; } ?> >b</option>
<option <?php if ($_POST['proc-select-5']==c) {echo "selected='selected'"; } ?> >c</option>
<option <?php if ($_POST['proc-select-5']==d) {echo "selected='selected'"; } ?> >d</option>
</select>
<select id="port-select-5" name="port-select-5">
<option disabled="disabled" SELECTED >Port</option>
<option <?php if ($_POST['port-select-5']==0) {echo "selected='selected'"; } ?> >0</option>
<option <?php if ($_POST['port-select-5']==1) {echo "selected='selected'"; } ?> >1</option>
</select>
</div>
</div>
<div class="wrap-quest-resp" id="fa6" style="display:none;" >
<div class="input-quest-no-height">FA and port - 6</div>
<div class="input-resp-no-height">
<select id="fa-select-6" name="fa-select-6">
<option disabled="disabled" SELECTED >Dir</option>
<option <?php if ($_POST['fa-select-6']==1) {echo "selected='selected'"; } ?> >1</option>
<option <?php if ($_POST['fa-select-6']==2) {echo "selected='selected'"; } ?> >2</option>
<option <?php if ($_POST['fa-select-6']==3) {echo "selected='selected'"; } ?> >3</option>
<option <?php if ($_POST['fa-select-6']==4) {echo "selected='selected'"; } ?> >4</option>
<option <?php if ($_POST['fa-select-6']==5) {echo "selected='selected'"; } ?> >5</option>
<option <?php if ($_POST['fa-select-6']==6) {echo "selected='selected'"; } ?> >6</option>
<option <?php if ($_POST['fa-select-6']==7) {echo "selected='selected'"; } ?> >7</option>
<option <?php if ($_POST['fa-select-6']==8) {echo "selected='selected'"; } ?> >8</option>
<option <?php if ($_POST['fa-select-6']==9) {echo "selected='selected'"; } ?> >9</option>
<option <?php if ($_POST['fa-select-6']==10) {echo "selected='selected'"; } ?> >10</option>
<option <?php if ($_POST['fa-select-6']==11) {echo "selected='selected'"; } ?> >11</option>
<option <?php if ($_POST['fa-select-6']==12) {echo "selected='selected'"; } ?> >12</option>
<option <?php if ($_POST['fa-select-6']==13) {echo "selected='selected'"; } ?> >13</option>
<option <?php if ($_POST['fa-select-6']==14) {echo "selected='selected'"; } ?> >14</option>
<option <?php if ($_POST['fa-select-6']==15) {echo "selected='selected'"; } ?> >15</option>
<option <?php if ($_POST['fa-select-6']==16) {echo "selected='selected'"; } ?> >16</option>
</select>
<select id="proc-select-6" name="proc-select-6">
<option disabled="disabled" SELECTED >Proc</option>
<option <?php if ($_POST['proc-select-6']==a) {echo "selected='selected'"; } ?> >a</option>
<option <?php if ($_POST['proc-select-6']==b) {echo "selected='selected'"; } ?> >b</option>
<option <?php if ($_POST['proc-select-6']==c) {echo "selected='selected'"; } ?> >c</option>
<option <?php if ($_POST['proc-select-6']==d) {echo "selected='selected'"; } ?> >d</option>
</select>
<select id="port-select-6" name="port-select-6">
<option disabled="disabled" SELECTED >Port</option>
<option <?php if ($_POST['port-select-6']==0) {echo "selected='selected'"; } ?> >0</option>
<option <?php if ($_POST['port-select-6']==1) {echo "selected='selected'"; } ?> >1</option>
</select>
</div>
</div>
<div class="wrap-quest-resp" id="fa7" style="display:none;" >
<div class="input-quest-no-height">FA and port - 7</div>
<div class="input-resp-no-height">
<select id="fa-select-7" name="fa-select-7">
<option disabled="disabled" SELECTED >Dir</option>
<option <?php if ($_POST['fa-select-7']==1) {echo "selected='selected'"; } ?> >1</option>
<option <?php if ($_POST['fa-select-7']==2) {echo "selected='selected'"; } ?> >2</option>
<option <?php if ($_POST['fa-select-7']==3) {echo "selected='selected'"; } ?> >3</option>
<option <?php if ($_POST['fa-select-7']==4) {echo "selected='selected'"; } ?> >4</option>
<option <?php if ($_POST['fa-select-7']==5) {echo "selected='selected'"; } ?> >5</option>
<option <?php if ($_POST['fa-select-7']==6) {echo "selected='selected'"; } ?> >6</option>
<option <?php if ($_POST['fa-select-7']==7) {echo "selected='selected'"; } ?> >7</option>
<option <?php if ($_POST['fa-select-7']==8) {echo "selected='selected'"; } ?> >8</option>
<option <?php if ($_POST['fa-select-7']==9) {echo "selected='selected'"; } ?> >9</option>
<option <?php if ($_POST['fa-select-7']==10) {echo "selected='selected'"; } ?> >10</option>
<option <?php if ($_POST['fa-select-7']==11) {echo "selected='selected'"; } ?> >11</option>
<option <?php if ($_POST['fa-select-7']==12) {echo "selected='selected'"; } ?> >12</option>
<option <?php if ($_POST['fa-select-7']==13) {echo "selected='selected'"; } ?> >13</option>
<option <?php if ($_POST['fa-select-7']==14) {echo "selected='selected'"; } ?> >14</option>
<option <?php if ($_POST['fa-select-7']==15) {echo "selected='selected'"; } ?> >15</option>
<option <?php if ($_POST['fa-select-7']==16) {echo "selected='selected'"; } ?> >16</option>
</select>
<select id="proc-select-7" name="proc-select-7">
<option disabled="disabled" SELECTED >Proc</option>
<option <?php if ($_POST['proc-select-7']==a) {echo "selected='selected'"; } ?> >a</option>
<option <?php if ($_POST['proc-select-7']==b) {echo "selected='selected'"; } ?> >b</option>
<option <?php if ($_POST['proc-select-7']==c) {echo "selected='selected'"; } ?> >c</option>
<option <?php if ($_POST['proc-select-7']==d) {echo "selected='selected'"; } ?> >d</option>
</select>
<select id="port-select-7" name="port-select-7">
<option disabled="disabled" SELECTED >Port</option>
<option <?php if ($_POST['port-select-7']==0) {echo "selected='selected'"; } ?> >0</option>
<option <?php if ($_POST['port-select-7']==1) {echo "selected='selected'"; } ?> >1</option>
</select>
</div>
</div>
<div class="wrap-quest-resp" id="fa8" style="display:none;" >
<div class="input-quest-no-height">FA and port - 8</div>
<div class="input-resp-no-height">
<select id="fa-select-8" name="fa-select-8">
<option disabled="disabled" SELECTED >Dir</option>
<option <?php if ($_POST['fa-select-8']==1) {echo "selected='selected'"; } ?> >1</option>
<option <?php if ($_POST['fa-select-8']==2) {echo "selected='selected'"; } ?> >2</option>
<option <?php if ($_POST['fa-select-8']==3) {echo "selected='selected'"; } ?> >3</option>
<option <?php if ($_POST['fa-select-8']==4) {echo "selected='selected'"; } ?> >4</option>
<option <?php if ($_POST['fa-select-8']==5) {echo "selected='selected'"; } ?> >5</option>
<option <?php if ($_POST['fa-select-8']==6) {echo "selected='selected'"; } ?> >6</option>
<option <?php if ($_POST['fa-select-8']==7) {echo "selected='selected'"; } ?> >7</option>
<option <?php if ($_POST['fa-select-8']==8) {echo "selected='selected'"; } ?> >8</option>
<option <?php if ($_POST['fa-select-8']==9) {echo "selected='selected'"; } ?> >9</option>
<option <?php if ($_POST['fa-select-8']==10) {echo "selected='selected'"; } ?> >10</option>
<option <?php if ($_POST['fa-select-8']==11) {echo "selected='selected'"; } ?> >11</option>
<option <?php if ($_POST['fa-select-8']==12) {echo "selected='selected'"; } ?> >12</option>
<option <?php if ($_POST['fa-select-8']==13) {echo "selected='selected'"; } ?> >13</option>
<option <?php if ($_POST['fa-select-8']==14) {echo "selected='selected'"; } ?> >14</option>
<option <?php if ($_POST['fa-select-8']==15) {echo "selected='selected'"; } ?> >15</option>
<option <?php if ($_POST['fa-select-8']==16) {echo "selected='selected'"; } ?> >16</option>
</select>
<select id="proc-select-8" name="proc-select-8">
<option disabled="disabled" SELECTED >Proc</option>
<option <?php if ($_POST['proc-select-8']==a) {echo "selected='selected'"; } ?> >a</option>
<option <?php if ($_POST['proc-select-8']==b) {echo "selected='selected'"; } ?> >b</option>
<option <?php if ($_POST['proc-select-8']==c) {echo "selected='selected'"; } ?> >c</option>
<option <?php if ($_POST['proc-select-8']==d) {echo "selected='selected'"; } ?> >d</option>
</select>
<select id="port-select-8" name="port-select-8">
<option disabled="disabled" SELECTED >Port</option>
<option <?php if ($_POST['port-select-8']==0) {echo "selected='selected'"; } ?> >0</option>
<option <?php if ($_POST['port-select-8']==1) {echo "selected='selected'"; } ?> >1</option>
</select>
</div>
</div>
<div class="add_remove_column">
<input type="hidden" id="countfa" name="countfa" value="3" readonly>
<button type="button" onClick="AddNewFa();" id="addfa" > + Add New FA </button>
<button type="button" onClick="RemoveNewFa();" id="removefa" disabled="disabled"> - Remove FA</button>
</div>
</div>
My javascript to add\remove hidden divs(minimum it will show two divs and max 8, I have added to disable add or remove buttons depends upn on its max \min count)
function AddNewFa()
{
var facount = parseInt($('#countfa').val(),9) ;
if( facount < 9)
{
facount = facount+1;
for(i=3;i<9;i++)
{
if( i<facount )
$('#fa'+i).slideDown("fast");
else
$('#fa'+i).slideUp("fast");
}
$('#countfa').val(facount);
}
if( facount ==9 )
{ $('#addfa').attr('disabled','disabled');}
if( facount ==4 )
{ $('#removefa').removeAttr("disabled");}
}
//removing fa clicking remove button
function RemoveNewFa()
{
var facount = parseInt($('#countfa').val(),10) ;
if( facount >3)
{
facount = facount-1;
for(i=3;i<10;i++)
{
if( i<facount )
$('#fa'+i).slideDown("fast");
else
$('#fa'+i).slideUp("fast");
}
$('#countfa').val(facount);
}
if( facount ==3 )
{ $('#removefa').attr('disabled','disabled');}
if( facount =8 )
{ $('#addfa').removeAttr("disabled"); }
}
Related
I used below code. But 1st --> returns 1sT --> I need 1ST
<option value="1ST"
<?php if (in_array("1ST", $_POST['pay_day'])) echo selected; ?>
> 1ˢᵀ </option>
<option value="2ND"
<?php if (in_array("2ND", $_POST['pay_day'])) echo selected; ?>
> 2ᴺᴰ </option>
<option value="3RD"
<?php if (in_array("3RD", $_POST['pay_day'])) echo selected; ?>
> 3ᴿᴰ </option>
<option value="4TH"
<?php if (in_array("4TH", $_POST['pay_day'])) echo selected; ?>
> 4ᵀᴴ </option>
<option value="5TH"
<?php if (in_array("5TH", $_POST['pay_day'])) echo selected; ?>
> 5ᵀᴴ </option>
Please help
<option value="1ST" <?php if (in_array("1ST", $_POST['pay_day'])) echo selected; ?> > 1<span style="text-transform: capitalize;">ˢᵀ</span></option>
<option value="2ND" <?php if (in_array("2ND", $_POST['pay_day'])) echo selected; ?> > 2<span style="text-transform: capitalize;">ᴺᴰ</span> </option>
<option value="3RD" <?php if (in_array("3RD", $_POST['pay_day'])) echo selected; ?> > 3<span style="text-transform: capitalize;">ᴿᴰ</span> </option>
<option value="4TH" <?php if (in_array("4TH", $_POST['pay_day'])) echo selected; ?> > 4<span style="text-transform: capitalize;">ᵀᴴ</span> </option>
<option value="5TH" <?php if (in_array("5TH", $_POST['pay_day'])) echo selected; ?> > 5<span style="text-transform: capitalize;">ᵀᴴ</span> </option>
i am using https://www.geodata.solutions/ for getting country,state,city list
And everything is working fine and i am able to save the data to databse
<select name="country" class="countries" id="countryId">
<option value="">Select Country</option>
</select>
<select name="state" class="states" id="stateId">
<option value="">Select State</option>
</select>
<select name="city" class="cities" id="cityId">
<option value="">Select City</option>
</select>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//geodata.solutions/includes/countrystatecity.js"></script>
Now i have to show the user to selected option
if $country , $state, $city are the details i fetched from the data base
so i change the html to following
<select name="country" class="countries" id="countryId">
<?php if($country!==""){?>
<option value="<?php echo $country; ?>" selected><?php echo $country; ?></option>
<?php } else { ?>
<option value="">Select Country</option>
<?php } ?>
</select>
<select name="state" class="states" id="stateId">
<?php if($state!==""){?>
<option value="<?php echo $state; ?>" selected><?php echo $state; ?>
</option>
<?php } else { ?>
<option value="">Select State</option>
<?php } ?>
</select>
<select name="city" class="cities" id="cityId">
<?php if($city!==""){?>
<option value="<?php echo $city; ?>" selected><?php echo $city; ?>
</option>
<?php } else { ?>
<option value="">Select City</option>
<?php } ?>
</select>
But Now the this is they are not ablue to change the dropdown . How can i solve this
i tried this also
<script>
jQuery(function($){
<?php if($country!==""){?>
var mySelect=$("#countryId");
mySelect.append(
$('<option value="<?php echo $country;?>" selected><?php echo
$country;?></option>'));
$('#countryId').trigger('change');
<?php } ?>
});
</script>
2) Question
I am checking for something that can integrate the country flag with the phone number field and i found https://intl-tel-input.com/. But now i have to select the country phone code automatically as per user change the country dropdown list in the fist select box . If there is any way we can make these each related ?
I have a small script, I did not made it, I want to modify it but Im stuck.
There are two select options, state and city. When state is selected ajax is bringing the specific cities for that state.
I have default value both for state and city but I cant trigger the city to change.
Here is the javascript
$("#state_id").change(function() {
$.ajax({
url: "<?php echo base_url() . "ajaxreq/getcity/"; ?>" + $("#state_id").val(),
success: function(result) {
$("#ajaxcity").html(result);
}
});
});
$('#state_id').trigger('change');
This is html part:
<div class="logininputfield">
<label><?php echo $this->lang->line('region') ?><span>*</span></label>
<div class="inputfieldsection">
<select name="state_id" id="state_id">
<option value=""><?= $this->lang->line("please_select"); ?> </option>
<?php foreach ($state as $key => $state_name) { ?>
<option value="<?php echo $key; ?>" <?php if ($state_id == $key ) { ?> selected <?php } ?> ><?php echo $state_name; ?></option>
<?php } ?>
</select>
<span for="state_id" class="error"></span>
</div>
</div>
<div class="logininputfield">
<label><?php echo $this->lang->line('city') ?><span>*</span></label>
<div class="inputfieldsection">
<span id="ajaxcity">
<select name="city" id="city" class="input span6">
<option value=""><?php echo $this->lang->line('please_select'); ?></option>
</select>
</span>
<span for="city" class="error"></span>
</div>
</div>
The result is this:
<div class="inputfieldsection">
<span id="ajaxcity"> <select name="city_id" id="city_id" class="valid">
<option value="102">München</option>
<option value="103">Nürnberg</option>
<option value="104">Augsburg</option>
<option value="105">Regensburg</option>
<option value="106">Ingolstadt</option>
<option value="107">Würzburg</option>
<option value="108">Fürth</option>
<option value="109">Erlangen</option>
<option value="110">Bayreuth</option>
<option value="111">Bamberg</option>
<option value="112">Aschaffenburg</option>
<option value="113">Landshut</option>
<option value="114">Kempten (Allgäu)</option>
<option value="115">Rosenheim</option>
<option value="116">Neu-Ulm</option>
<option value="117">Schweinfurt</option>
<option value="118">Passau</option>
<option value="119">Freising</option>
<option value="120">Dachau</option>
<option value="121">Straubing</option>
<option value="122">Hof</option>
<option value="123">Memmingen</option>
<option value="124">Kaufbeuren</option>
<option value="125">Weiden in der Oberpfalz</option>
<option value="126">Amberg</option>
<option value="127">Coburg</option>
<option value="128">Ansbach</option>
<option value="129">Schwabach</option>
<option value="130">Germering</option>
<option value="131">Neumarkt in der Oberpfalz</option>
<option value="132">Erding</option>
<option value="133">Fürstenfeldbruck</option>
<option value="134">Deggendorf</option>
<option value="135">Forchheim</option>
<option value="136">Friedberg</option>
<option value="137">Neuburg an der Donau</option>
<option value="138">Landsberg am Lech</option>
<option value="139">Schwandorf</option>
<option value="140">Königsbrunn</option>
<option value="141">Unterschleißheim</option>
<option value="142">Kulmbach</option>
<option value="143">Olching</option>
<option value="144">Garmisch-Partenkirchen</option>
<option value="145">Lauf an der Pegnitz</option>
<option value="146">Zirndorf</option>
<option value="147">Lindau</option>
<option value="148">Pfaffenhofen an der Ilm</option>
<option value="149">Roth</option>
<option value="150">Geretsried</option>
<option value="151">Unterhaching</option>
<option value="152">Herzogenaurach</option>
<option value="153">Starnberg</option>
<option value="154">Waldkraiburg</option>
<option value="155">Vaterstetten</option>
<option value="156">Senden</option>
<option value="157">Weilheim in Oberbayern</option>
<option value="158">Sonthofen</option>
<option value="159">Neusäß</option>
<option value="160">Gersthofen</option>
<option value="161">Bad Kissingen</option>
<option value="162">Ottobrunn</option>
<option value="163">Aichach</option>
<option value="164">Puchheim</option>
<option value="165">Kitzingen</option>
<option value="166">Traunreut</option>
<option value="167">Gauting</option>
<option value="168">Lichtenfels</option>
</select><span for="city_id" class="error"></span>
</span>
<span for="city" class="error"></span>
</div>
I'm a noob with javascript.
I added myself the trigger part and it works but I dont know how to make it work for the city.
It would be something like this but is it doesnt work.
$('#city_id').val(<? echo $city_id; ?>).trigger('change');
Thank you in advance.
This was the answer i was looking for
<?php foreach ($city as $key => $city_name) { ?>
<option value="<?php echo $key; ?>" <?php if($city_id == $key) {?> selected <?php } ?> ><?php echo $city_name; ?></option>
<?php } ?>
I have got this problem that is driving me crazy. I have made this Javascript function that is working in every browser and only in IE9 and lower I get this error.
This is the error I got in dutch.
SCRIPT5007: Kan de eigenschap value van een niet-gedefinieerde verwijzing of een verwijzing naar een lege waarde niet instellen
This is the translated version:
SCRIPT5007: Can the value property of an undefined reference or a reference to an empty value not set.
This is my Javascript function:
function Calculate()
{
var l = document.getElementById('aantal-caps').value;
var l2 = document.getElementById('aantal-paraplu').value;
var l3 = document.getElementById('aantal-blue-tooth').value;
var l4 = document.getElementById('aantal-backpack').value;
var result = l * 12 + l2 * 12 + l3 * 20 + l4 * 50;
document.getElementById('totaal').innerHTML = result;
document.aanvraag.totaal.value = result;
var punten = 345; // Aantal spaarpunten van de klant. Die kan jij hier inschieten.
var bereken = punten - result;
if(bereken < 0)
{
bereken = '<span style="color:#ff0000"><b>Saldo niet toereikend</b></span>';
document.getElementById("Submitform").disabled = true;
} else
{
bereken = punten - result;
document.getElementById("Submitform").disabled = false;
}
document.getElementById('punten-aantal').innerHTML = bereken;
document.getElementById('uwpunten').innerHTML = punten;
}
window.onload=Calculate;
This is my HTML table where I show the selected javascript values:
<table style="float:left; width:350px; height:247px;">
<tr>
<th height="15px">Spaarpunten</th>
</tr>
<tr>
<td>Uw aantal spaarpunten : </td>
<td><strong style="font-size:14px"><span id="uwpunten" style="color:#0acb00;">0<input type="hidden" name="uwpunten" id="uwpunten" value="" /></span></strong></td>
</tr>
<tr>
<td>De huidige selectie kost u : </td>
<td><strong style="font-size:14px"><span id="totaal" style="color:#F00;">0<input type="hidden" name="totaal" id="totaal" value="" /></span></strong></td>
</tr>
<tr>
<td>-------------------------------</td>
<td>-----</td>
</tr>
<tr>
<td>U heeft nog : </td>
<td><strong style="font-size:14px"><span id="punten-aantal" style="color:#0acb00;">0<input type="hidden" name="punten-aantal" id="punten-aantal" value="" /></span></strong></td>
</tr>
This is my selection form:
<table width="700" cellpadding="3" cellspacing="3" style="float:left;">
<tr>
<th>Kies een product</th>
</tr>
<tr>
<td><img src="cap.jpg" /></td>
<td><img src="paraplu.jpg" /></td>
<td><img src="bandenspeaker.jpg" /></td>
<td><img src="backpack.jpg" /></td>
</tr>
<tr>
<td><select id="aantal-caps" name="aantal-caps" onChange="Calculate();">
<option value="0" selected="selected">Kies het aantal</option>
<option value="1" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-caps']) == "1") {echo "selected='selected'"; } ?>>1</option>
<option value="2" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-caps']) == "2") {echo "selected='selected'"; } ?>>2</option>
<option value="3" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-caps']) == "3") {echo "selected='selected'"; } ?>>3</option>
<option value="4" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-caps']) == "4") {echo "selected='selected'"; } ?>>4</option>
<option value="5" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-caps']) == "5") {echo "selected='selected'"; } ?>>5</option>
<option value="6" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-caps']) == "6") {echo "selected='selected'"; } ?>>6</option>
<option value="7" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-caps']) == "7") {echo "selected='selected'"; } ?>>7</option>
<option value="8" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-caps']) == "8") {echo "selected='selected'"; } ?>>8</option>
<option value="9" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-caps']) == "9") {echo "selected='selected'"; } ?>>9</option>
<option value="10" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-caps']) == "10") {echo "selected='selected'"; } ?>>10</option>
</select>
</td>
<td><select id="aantal-paraplu" name="aantal-paraplu" onChange="Calculate();">
<option value="0" selected="selected">Kies het aantal</option>
<option value="1" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-paraplu']) == "1") {echo "selected='selected'"; } ?>>1</option>
<option value="2" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-paraplu']) == "2") {echo "selected='selected'"; } ?>>2</option>
<option value="3" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-paraplu']) == "3") {echo "selected='selected'"; } ?>>3</option>
<option value="4" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-paraplu']) == "4") {echo "selected='selected'"; } ?>>4</option>
<option value="5" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-paraplu']) == "5") {echo "selected='selected'"; } ?>>5</option>
<option value="6" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-paraplu']) == "6") {echo "selected='selected'"; } ?>>6</option>
<option value="7" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-paraplu']) == "7") {echo "selected='selected'"; } ?>>7</option>
<option value="8" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-paraplu']) == "8") {echo "selected='selected'"; } ?>>8</option>
<option value="9" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-paraplu']) == "9") {echo "selected='selected'"; } ?>>9</option>
<option value="10" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-paraplu']) == "10") {echo "selected='selected'"; } ?>>10</option>
</select>
</td>
<td><select id="aantal-blue-tooth" name="aantal-blue-tooth" onChange="Calculate();">
<option value="0" selected="selected">Kies het aantal</option>
<option value="1" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-blue-tooth']) == "1") {echo "selected='selected'"; } ?>>1</option>
<option value="2" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-blue-tooth']) == "2") {echo "selected='selected'"; } ?>>2</option>
<option value="3" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-blue-tooth']) == "3") {echo "selected='selected'"; } ?>>3</option>
<option value="4" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-blue-tooth']) == "4") {echo "selected='selected'"; } ?>>4</option>
<option value="5" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-blue-tooth']) == "5") {echo "selected='selected'"; } ?>>5</option>
<option value="6" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-blue-tooth']) == "6") {echo "selected='selected'"; } ?>>6</option>
<option value="7" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-blue-tooth']) == "7") {echo "selected='selected'"; } ?>>7</option>
<option value="8" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-blue-tooth']) == "8") {echo "selected='selected'"; } ?>>8</option>
<option value="9" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-blue-tooth']) == "9") {echo "selected='selected'"; } ?>>9</option>
<option value="10" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-blue-tooth']) == "10") {echo "selected='selected'"; } ?>>10</option>
</select>
</td>
<td><select id="aantal-backpack" name="aantal-backpack" onChange="Calculate();">
<option value="0" selected="selected">Kies het aantal</option>
<option value="1" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-backpack']) == "1") {echo "selected='selected'"; } ?>>1</option>
<option value="2" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-backpack']) == "2") {echo "selected='selected'"; } ?>>2</option>
<option value="3" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-backpack']) == "3") {echo "selected='selected'"; } ?>>3</option>
<option value="4" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-backpack']) == "4") {echo "selected='selected'"; } ?>>4</option>
<option value="5" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-backpack']) == "5") {echo "selected='selected'"; } ?>>5</option>
<option value="6" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-backpack']) == "6") {echo "selected='selected'"; } ?>>6</option>
<option value="7" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-backpack']) == "7") {echo "selected='selected'"; } ?>>7</option>
<option value="8" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-backpack']) == "8") {echo "selected='selected'"; } ?>>8</option>
<option value="9" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-backpack']) == "9") {echo "selected='selected'"; } ?>>9</option>
<option value="10" <?php if(isset($_POST['Submitform']) && strip_tags($_POST['aantal-backpack']) == "10") {echo "selected='selected'"; } ?>>10</option>
</select>
</td>
</tr>
Sorry for posting all the code but most of the time it is better to understand what I'm doing.
This field:
<td><strong style="font-size:14px"><span id="totaal" style="color:#F00;">0<input type="hidden" name="totaal" id="totaal" value="" /></span></strong></td>
is the only field that is working. Other two fields I get SCRIPT5007 ERROR on page load and when I select another field in my form.
Why is this only happening in IE9 and lower? And is there a way to solve this issue?
document.aanvraag.totaal.value = result;
That was causing my error
I have this menu:
Classificazione <select onchange="if(this.value == 'D'){ document.getElementById('menu2').style.display = 'block'; } else { document.getElementById('menu2').style.display = 'none'; }" style="margin-top: 5px;" name="classificazione">
<option value="art0"></option>
<option value="C" <?php if (isset($getParams['classificazione'])&&$getParams['classificazione']=="C") echo "selected"; ?> >Articoli</option>
<option value="D" <?php if (isset($getParams['classificazione'])&&$getParams['classificazione']=="D") echo "selected"; ?> >Documentazione</option>
<option value="A" <?php if (isset($getParams['classificazione'])&&$getParams['classificazione']=="A") echo "selected"; ?> >Libri</option>
<option value="G" <?php if (isset($getParams['classificazione'])&&$getParams['classificazione']=="G") echo "selected"; ?> >Materiali</option>
<option value="B" <?php if (isset($getParams['classificazione'])&&$getParams['classificazione']=="B") echo "selected"; ?> >Riviste</option>
</select><br />
Only when the user selects the value 'Documentazione' I want to show another (equal) menu, with different option.
I added this submenu:
<select style="margin-top: 5px;" name="menu2">
<option value="art0"></option>
<option value="C" >Corsi</option>
<option value="D" >Incontri</option>
<option value="A" >Convegni</option>
<option value="G" >Gruppi</option>
<option value="B" >Progetto</option>
</select><br />
But it's not working
Classificazione <select onchange="if(this.value == 'D'){ document.getElementById('menu2').style.display = 'block'; } else { document.getElementById('menu2').style.display = 'none'; }" style="margin-top: 5px;" name="classificazione">
<option value="art0"></option>
<option value="C" <?php if ($getParams['classificazione']=="C") echo "selected"; ?> >Articoli</option>
<option value="D" <?php if ($getParams['classificazione']=="D") echo "selected"; ?> >Documentazione</option>
<option value="A" <?php if ($getParams['classificazione']=="A") echo "selected"; ?> >Libri</option>
<option value="G" <?php if ($getParams['classificazione']=="G") echo "selected"; ?> >Materiali</option>
<option value="B" <?php if ($getParams['classificazione']=="B") echo "selected"; ?> >Riviste</option>
</select>
notice the onchange event.
<select style="margin-top: 5px; display: none;" id="menu2">
<option value="art0"></option>
<option value="C" >Corsi</option>
<option value="D" >Incontri</option>
<option value="A" >Convegni</option>
<option value="G" >Gruppi</option>
<option value="B" >Progetto</option></select>