Guest User

Untitled

a guest
Jan 18th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.25 KB | None | 0 0
  1. <li>
  2. <select name="names" id="names">
  3. <option value="">Constituency</option>
  4. <!-- populates the drop down with names -->
  5. <?php foreach ($cons as $constituency): ?>
  6. <option value="<?php htmlout($constituency['ids']); ?>">
  7. <?php htmlout($constituency['names']); ?>
  8. </option>
  9. <?php endforeach; ?>
  10. <?php if (isset($selectError)): ?>
  11. <p><?php htmlout($selectError); ?></p>
  12. <?php endif; ?>
  13. </select>
  14. </li>
  15.  
  16. <li><input type="hidden" name="action" value="search"></li>
  17. <li><input type="submit" value="SEARCH" class="button search" id="jsbutton" disabled="disabled"></li>
  18.  
  19. $(document).ready(function() {
  20.  
  21. if ($('#names').val() = '')
  22. {
  23. $('#jsbutton').attr('disabled', 'disabled');
  24. }
  25. else
  26. {
  27. $('#jsbutton').removeAttr('disabled');
  28. }
  29. });
  30.  
  31. try
  32. {
  33. $cons_result = $pdo->query("SELECT id, name
  34. FROM constituency
  35. ORDER BY name");
  36. }
  37. catch (PDOException $e)
  38. {
  39. $error = 'Error fetching constituencies from database!' . $e->getMessage();
  40. include 'error.html.php';
  41. exit();
  42. }
  43.  
  44.  
  45. foreach ($cons_result as $rows)
  46. {
  47. $cons[] = array('ids' => $rows['id'], 'names' => $rows['name']);
  48. }
  49.  
  50. include 'searchform.html.php';
  51. }
  52.  
  53. $(document).ready(function() {
  54. $("#names").change(function () {
  55. var str = "";
  56. if ($("#names option:selected").val()=='')
  57. {
  58.  
  59. $('#jsbutton').attr('disabled', 'disabled');
  60. }
  61. else
  62. {
  63.  
  64. $('#jsbutton').removeAttr('disabled');
  65. }
  66. });
  67. });
  68.  
  69. <select id="names">
  70. <option value=0>Please Select</option>
  71. <?php ($cons as $constituency) {...} ?>
  72. </select>
  73. <input id="jsbutton" type="submit" disabled />
  74.  
  75. $(function(){
  76. $('#names').change(function(e) {
  77. if ($(this).prop("selectedIndex") === 0)
  78. {
  79. $('#jsbutton').prop('disabled', true);
  80. }
  81. else
  82. {
  83. $('#jsbutton').prop('disabled', false);
  84. }
  85. });
  86. });
  87.  
  88. $(document).ready(function() {
  89. $('#names').change(function() {
  90. if ($('#names').val() == '')
  91. {
  92. $('#jsbutton').attr('disabled', 'disabled');
  93. }
  94. else
  95. {
  96. $('#jsbutton').removeAttr('disabled');
  97. }
  98. }
  99. });
  100.  
  101. <li>
  102. <select name="names" id="names" onChange='editButton(this.value);'>
  103. <option value="">Constituency</option>
  104. <!-- populates the drop down with names -->
  105. <?php foreach ($cons as $constituency): ?>
  106. <option value="<?php htmlout($constituency['ids']); ?>">
  107. <?php htmlout($constituency['names']); ?>
  108. </option>
  109. <?php endforeach; ?>
  110. <?php if (isset($selectError)): ?>
  111. <p><?php htmlout($selectError); ?></p>
  112. <?php endif; ?>
  113. </select>
  114. </li>
  115.  
  116. <li><input type="hidden" name="action" value="search"></li>
  117. <li><input type="submit" value="SEARCH" class="button search" id="jsbutton" disabled="disabled"></li>
  118.  
  119. <script type='text/javascript'>
  120. function editButton(value){
  121. if (value == '')
  122. {
  123. $('#jsbutton').attr('disabled', 'disabled');
  124. }
  125. else
  126. {
  127. $('#jsbutton').removeAttr('disabled');
  128. }
  129. }
  130. </script>
  131.  
  132. $('#names').val() =='' instead of $('#names').val() = ''
Add Comment
Please, Sign In to add comment