Jump to content

How To Disable A Field Only For A Specific Scenarios


heshan

Recommended Posts

Hi All,

 

I have a student form which is used to select grade, class, stream and payment status from drop down lists. Thereafter it can be used to generate reports which are useful when finding students who are paid student fees and who are not paid fees.

 

The 'stream' field ONLY uses when the user selects grade 12 or 13. Otherwise it should be disabled. How this can be achieved using javascript and PHP?? I have tried something like this. But it is not working...

 

if(grade >=1 && grade<= 11): echo " disabled"; endif; ?>>

 

  <tr>
    <td> </td>
    <td width="117" align="center"><label>Grade</label>
	   </td>
    <td width="69"><label>
	  <select name="grade" id="select2">
	    <option>1</option>
	    <option>2</option>
	    <option>3</option>
	    <option>4</option>
	    <option>5</option>
	    <option>6</option>
	    <option>7</option>
	    <option>8</option>
	    <option>9</option>
	    <option>10</option>
	    <option>11</option>
	    <option>12</option>
	    <option>13</option>
			    </select>
    </label></td>
    <td width="1" align="center"> </td>
    <td align="center"><label>Class</label>
	   </td>
    <td width="71"><label>
	  <select name="class" id="select3">
	    <option>A</option>
	    <option>B</option>
	    <option>C</option>
	    <option>D</option>
	    <option>E</option>
	    <option>F</option>
			    </select>
    </label></td>
    <td width="69" align="center"><label>Stream</label>
	   </td>
    <td><select name="stream" id="jumpMenu3" <?php if(grade >=1 && grade<= 11): echo " disabled"; endif; ?>>
	    <option>Maths</option>
	    <option>Science</option>
	    <option>Commerce</option>
	    <option>Art</option>
    </select></td>
  </tr>
  <tr>
    <td colspan="2">Payment Status</td>
    <td colspan="2"><label>
	  <select name="payment_status" id="select">
	    <option value="Y">Paid</option>
	    <option value="N">Not Paid</option>
	  </select>
    </label></td>
    <td> </td>
    <td colspan="2"> </td>
    <td> </td>
  </tr>
  <tr>

For one, In PHP variables start with a $. And $grade needs to be defined.

 

But if you're saying that immediately when the user selects 12 or 13, the field should be enabled, yes, that has to be javascript. Of which you have written none.

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.