Search Results

Search found 1 results on 1 pages for 'stevej313'.

Page 1/1 | 1 

  • Disabling Text field with Javascript when value in drop down box is from mysql

    - by SteveJ313
    Hi I have a simple script in HTML, using a dropdown menu. When the value 1 is selected, the user can write in the text field, if value 2 is selected, it disables the text field. However, i changed the values of the dropdown menu, so that one value was from a mysql table(using PHP) and the other remained 'option value='1''. Yet now neither text field is disabled. Below is the code. `<script type="text/javascript"> function findselected() { if (document.form.selmenu.value == <?php echo $id; ?>) { document.form.txtField.disabled=true; // return false; // not sure this line is needed } else { document.form.txtField.disabled=false; // return false; // not sure this line is needed } } ` And the PHP section if(mysql_num_rows($SQL) == 1) { echo "<select name='selmenu' onChange='findselected()'>"; echo "<label>TCA_Subject</label>"; while ($row=mysql_fetch_array($SQL)) { echo "<option value='$id'>$thing</option>"; echo "<option value='2'>Choice 2</option>"; } } echo "<option value=$userid>'Choice 1'</option>"; ?> <option value='2'>Choice 2</option>"; </select> I have tried taking the second option value out of the loop, putting it into html, editing the variable in the javascript function. There is not a fault with the PHP as it is retrieving the right results and displaying it, yet the text field doesnt become disabled. Does anyone know of a possible solution? Thanks

    Read the article

1