Jump to content

balkan7

Members
  • Posts

    234
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

balkan7's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. Hi hansford Thanks for helping but i think this is not the best solution because if i had in database question with 5 answers and when i edit this will look same: <? foreach($result as $data) { echo '<input type="text" name="answers[]" class="required-fields" value="'.$data['answer'].'" />'; } ?> I think is better to use for loop for limit inputs....
  2. Hi How can limit only required input fields cannot be empty. <form name="test" method="post" action="test.php"> <label for="quest"> <input type="text" name="quest" /> <!-- REQUIRED --> </label> <label for="answers"> <input type="text" name="answers[]" /> <!-- REQUIRED --> </label> <label for="answers"> <input type="text" name="answers[]" /> <!-- REQUIRED --> </label> <label for="answers"> <input type="text" name="answers[]" /> </label> <label for="answers"> <input type="text" name="answers[]" /> </label> <label for="answers"> <input type="text" name="answers[]" /> </label> <label for="submit"> <input type="submit" name="submit" value="Submit" /> </label> </form> Following function working only on all empty input fields, i need help to enable button when required fields is not empty. $(document).ready(function() { var $submit = $("input[type=submit]"), $inputs = $('input[name=quest], input[name=answers[]]'); function checkEmpty() { // filter over the empty inputs return $inputs.filter(function() { return !$.trim(this.value); }).length === 0; } $inputs.on('keyup', function() { $submit.prop("disabled", !checkEmpty()); }).keyup(); // trigger an initial blur });
  3. Hi, i need help for get data from following tables: questions: id question options: id ques_id value votes: id option_id voted_on ip Question: What is your favorite color. Option1: Test 1 - 83 votes Option2: Test 2 - 0 votes Option3: Test 3 - 51 votes I'm using this sql for result: SELECT options.id, options.value, COUNT(*) as votes FROM votes, options WHERE votes.option_id=options.id AND votes.option_id IN(SELECT id FROM options WHERE ques_id=2) GROUP BY votes.option_id; so i get this: id value votes 1 Test1 83 3 Test3 51 because there is not votes for option Test2 and doesn't show it. i need help to get all data like this: id value votes 1 Test1 83 2 Test2 0 3 Test3 51
  4. Hi Psycho Thanks for reply i found solution: $v = implode( "|", $votes ); $v = array($v); $a = implode( "|", $answers ); $a = array($a); $x = array_merge($check, $v, $a); echo json_encode($x);
  5. Thank you for reply DavidAM With this code i get result from array: function(data) { if (data[0] == "ok") { show_results(id,data[1],data[2], 'voted'); } data[1] = votes data[2] = values <button onClick="show_results('2','67|38|38|','Test1|Test2|Test3|','no'); return false;">Result</button>
  6. i have tried with this but i get this result: "ok","67|","38|","38|","Test1|","Test2|","Test3|" Pls help me to get this result: "ok","67|38|38|","Test1|Test2|Test3|" <? $answers = array(); $votes = array(); $check = array('ok'); foreach($results as $rows) { $votes[] = $rows['votes']."|"; $answers[] = $rows['value']."|"; } $test = array_merge($check, $votes, $answers); echo json_encode($test);
  7. Thank you for reply ginerjm. Actually i need this result: ok64|33|37|Test1|Test2|Test3| Because i send it to JSON: echo json_encode($check); After i get result i use javascript for each result: votes = votes.split("|"); values = values.split("|");
  8. Yes This is result of votes: 64|33|37| This is result of values: Test1|Test2|Test3| So i want this result push in array and get this result: ok64|33|37|Test1|Test2|Test3|
  9. I need help for get this result in foreach loop. ok64|33|37|Test1|Test2|Test3| But with my looping i get this result: ok64|Test1|33Test2|37|Test3| <? $check = array('ok'); foreach($results as $rows) { array_push($check, $rows['votes']."|"); array_push($check, $rows['value']."|"); } ?>
  10. Hi selathe Thanks for helping but i'm not able to install PECL extensions.
  11. Result for dates is: Quis nostrud 0510 Result for non dates is: Quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat.
  12. $text= "Quis nostrud 05.10.2011 exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat."; $regExp = '/^([^.]+)\\.\s/'; $replace = '<strong>$1</strong>.'; $text = preg_replace ($regExp, $replace, $text); $test = explode(".", $text); $display1 = nl2br($test[0]); $display2 = nl2br($test[1]); Result is: Quis nostrud 0510 (without apply tags <strong>)
  13. I'm trying this one but doesn't work $regExp = '/^([^.]+)\\.\s/';
  14. For the first, just add a space after the period in the RegExp. Should handle dates just fine then. Please example with regex
  15. Tested and working, but if exist date like 05.10.2011 highlighting stop in 05. can be this skip ? And text separated with two variables: $highlighted = "Quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."; $more = "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat.";
×
×
  • 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.