Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <li>
- <select name="names" id="names">
- <option value="">Constituency</option>
- <!-- populates the drop down with names -->
- <?php foreach ($cons as $constituency): ?>
- <option value="<?php htmlout($constituency['ids']); ?>">
- <?php htmlout($constituency['names']); ?>
- </option>
- <?php endforeach; ?>
- <?php if (isset($selectError)): ?>
- <p><?php htmlout($selectError); ?></p>
- <?php endif; ?>
- </select>
- </li>
- <li><input type="hidden" name="action" value="search"></li>
- <li><input type="submit" value="SEARCH" class="button search" id="jsbutton" disabled="disabled"></li>
- $(document).ready(function() {
- if ($('#names').val() = '')
- {
- $('#jsbutton').attr('disabled', 'disabled');
- }
- else
- {
- $('#jsbutton').removeAttr('disabled');
- }
- });
- try
- {
- $cons_result = $pdo->query("SELECT id, name
- FROM constituency
- ORDER BY name");
- }
- catch (PDOException $e)
- {
- $error = 'Error fetching constituencies from database!' . $e->getMessage();
- include 'error.html.php';
- exit();
- }
- foreach ($cons_result as $rows)
- {
- $cons[] = array('ids' => $rows['id'], 'names' => $rows['name']);
- }
- include 'searchform.html.php';
- }
- $(document).ready(function() {
- $("#names").change(function () {
- var str = "";
- if ($("#names option:selected").val()=='')
- {
- $('#jsbutton').attr('disabled', 'disabled');
- }
- else
- {
- $('#jsbutton').removeAttr('disabled');
- }
- });
- });
- <select id="names">
- <option value=0>Please Select</option>
- <?php ($cons as $constituency) {...} ?>
- </select>
- <input id="jsbutton" type="submit" disabled />
- $(function(){
- $('#names').change(function(e) {
- if ($(this).prop("selectedIndex") === 0)
- {
- $('#jsbutton').prop('disabled', true);
- }
- else
- {
- $('#jsbutton').prop('disabled', false);
- }
- });
- });
- $(document).ready(function() {
- $('#names').change(function() {
- if ($('#names').val() == '')
- {
- $('#jsbutton').attr('disabled', 'disabled');
- }
- else
- {
- $('#jsbutton').removeAttr('disabled');
- }
- }
- });
- <li>
- <select name="names" id="names" onChange='editButton(this.value);'>
- <option value="">Constituency</option>
- <!-- populates the drop down with names -->
- <?php foreach ($cons as $constituency): ?>
- <option value="<?php htmlout($constituency['ids']); ?>">
- <?php htmlout($constituency['names']); ?>
- </option>
- <?php endforeach; ?>
- <?php if (isset($selectError)): ?>
- <p><?php htmlout($selectError); ?></p>
- <?php endif; ?>
- </select>
- </li>
- <li><input type="hidden" name="action" value="search"></li>
- <li><input type="submit" value="SEARCH" class="button search" id="jsbutton" disabled="disabled"></li>
- <script type='text/javascript'>
- function editButton(value){
- if (value == '')
- {
- $('#jsbutton').attr('disabled', 'disabled');
- }
- else
- {
- $('#jsbutton').removeAttr('disabled');
- }
- }
- </script>
- $('#names').val() =='' instead of $('#names').val() = ''
Add Comment
Please, Sign In to add comment