mardi 27 juin 2017

Bootstrap 3 Collapse is not synchron with checkbox state

According to this question: "Twitter Bootstrap 3 collapse when checkbox checked" i've tried this solution, because it is simple and clean.

http://ift.tt/2thdOgA

<div class="panel-group driving-license-settings" id="accordion">
    <div class="panel panel-default">
        <div class="panel-heading">
             <h4 class="panel-title">
                                      <div class="checkbox">
                <label data-toggle="collapse" data-target="#collapseOne">
                    <input type="checkbox"/> I have Driver License  
                </label>
            </div>
                                  </h4>

        </div>
        <div id="collapseOne" class="panel-collapse collapse in">
            <div class="panel-body">
                <div class="driving-license-kind">
                    <div class="checkbox">
                        <input type="checkbox" value="">A</div>
                    <div class="checkbox">
                        <input type="checkbox" value="">B</div>
                    <div class="checkbox">
                        <input type="checkbox" value="">C</div>
                    <div class="checkbox">
                        <input type="checkbox" value="">D</div>
                    <div class="checkbox">
                        <input type="checkbox" value="">E</div>
                </div>
            </div>
        </div>
    </div>
</div>

But with this "solution" you have a problem. If you click the checkbox too fast, the area is collapsed but the checkbox is checked.

How can i prevent this double clicking problem?

I am using:

  • Bootstrap 3
  • jQuery 3.1.1



lundi 26 juin 2017

java - how to implement libGDX checkbox

I never used the checkbox of libGDX before, and I don't know how to start implementing it in a proper way to Android.
I want to change some things when the checkbox is set to true and change other things when it is set to false. Do I need to make if (checkbox.isChecked()) {...} else{...} at render()? or I need to add a ChangeListener to my checkBox? or a InputListener? or none of these? or all of these? (just kidding in the last question)




Scroll/position to bottom when new info appears in Divs (via CheckBox Selection)

I'm working on a page the asks the user to select from checkboxes, as they make their selections new info appears (based on the selected checkboxes). I'd like for the window to auto scroll as new info appears on the page.

I've research this online and could not find a solition that matches my coding. This is an example of my code bellow. I tried to use variation of

element.scrollTop = element.clientHeight; 

and

var $objDiv = $("#logtext");

$objDiv.scrollTop( $objDiv.height() );

<html>
 
<head>
 
<script>
element.scrollTop = element.clientHeight;
</script>

 
<script> 
var $objDiv = $("#logtext");
$objDiv.scrollTop( $objDiv.height() );
</script>
 
</head>
<body>
 

 
<form method="post" action="#">
 
 
  <h4>Select a fruit:</h4>
  <div>
    <div>
      <input type="checkbox" name="choice-apple” id="choice-apple” required>
      <label for="choice-apple”>Apple</label>
 
      <div class="reveal-if-active">
        <label for=“apple”><p><font color="purple">"I'm glad to Hear that!<br>Why do you like apples?”</label><br></p>
        <input type="button" value=“more apples" onclick = "location.href=‘apple1.html'">
      </div>
    </div>
 
<p><font color="black">
    <div>
 
      <input type="checkbox" name="choice-banana” id="choice-banana”>
      <label for="choice-banana”>Banana</label>
 
      <div class="reveal-if-active">
    <label for="negative"><p><font color="red">"I'm surprised to hear that. Why do you like bananas?</label><br></p>
        <input type="Button" value=“more bananas“ onclick = "location.href=‘bananas1.html'">
      </div>
    </div>
  </div>
 
</form>
<br> 
</html>

Thanks in advance.




PHP Checkbox Assign To Variable

This is what I am after here. If the checkbox is checked, then I want to assign these values

$begindate = '20160101';
$enddate = '20161231'

If the checkbox is NOT checked then I want to force the user to select from the date selectors, and if either date is null then throw an error. I have this syntax, and the issue I am having with it is that if the check box is checked AND the user inputs dates then the input dates over-write the checkbox dates. NOT what I want to happen. There may be other syntax flaws in here that my new self has not realized yet, but what needs to be changed in this syntax in order to make it flow properly and execute as I describe above?

    <body>
<form>
Display 2016 Data? &emsp; <input type = 'Checkbox' Name='twentysix' value="twentysix"><br>
<input type="submit" name="submit" value="Gather">
</form>
</body>
<?php
if (isset($_POST['submit'])) 
{
    if ( isset($_POST['twentysix']) ) {
        $begindate = '20160101';
        $enddate = '20161231'
    } else {
        $begindate = $begindate;
        $enddate = enddate;
    }
    $begindateerror = false;
    $enddateerror = false;
    if (empty($_POST['begindate'])) {
        $begindateerror = true;
    }
    if (empty($_POST['enddate'])) {
        $enddateerror = true;
    }
    if ($begindateerror) {
    echo "<strong>Please select a start date.</strong><br>";
    } else if ($enddateerror) {
        echo "<strong>Please select a end date.</strong><br>";
    } else {
        $begindate = $_POST['begindate'];
        $enddate = $_POST['enddate'];
    }
}




Insert Multiple Names, E-Mails or Text Messages Checkbox Values into a Database

I have looked throughout stackoverflow for the right solution to my particular problem, but because I not proficient in php I'm not able to figure this one out.

I have a form that list multiple users that have registered for a class. There are two groups for the sessioner's class. They are student attendees and sessioner attendees.

In this form, the sessioner can send an email or text message to one registrant or to all of the registrants from either group using the myCheckboxes[ ]. I have no problem emailing the email(s) or texting the text message(s) and inserting the online form's values into the database (I know I need to be using MySQLi) and thus, creating a row (id) for each myCheckboxes[ ].

The problem I have is not being able to insert the student attendee's or the sessioner attendee's name, email or text-number into the database fields toname, toemail or totext for each myCheckboxes[ ]. I don't know how to write the $_Post or the mysql insert to do this. Any help would be greatly appreciated.

Send E-Mail or Text Message Code

if ($_POST) {
$emails = array();
$count = 0;

$emails = $_POST['myCheckboxes'];

$fromname = $_POST['fromname'];
$fromemail = $_POST['fromemail'];
$tocc = $_POST['tocc'];
$emailsubject = $_POST['emailsubject'];
$yourmessage = $_POST['yourmessage'];

$sender_email = $fromemail; //sender email
$subject = $emailsubject; //subject of email
$message = $yourmessage; //message body

if ($_FILES['my_file']['name']) {
    //get file details we need
    $file_tmp_name = $_FILES['my_file']['tmp_name'];
    $file_name = $_FILES['my_file']['name'];
    $file_size = $_FILES['my_file']['size'];
    $file_type = $_FILES['my_file']['type'];
    $file_error = $_FILES['my_file']['error'];

    if ($file_error > 0) {
        die('upload error');
    }
    //read from the uploaded file & base64_encode content for the mail
    $handle = fopen($file_tmp_name, "r");
    $content = fread($handle, $file_size);
    fclose($handle);
    $encoded_content = chunk_split(base64_encode($content));

    $file_status = 1;
}

foreach ($emails as $email) {

    $boundary = md5("sanwebe");
    //header
    $headers = "MIME-Version: 1.0\r\n";
    $headers .= "From:" . $sender_email . "\r\n";

    $headers .= "CC: " . $tocc . "\r\n";
    $headers .= "Content-Type: multipart/mixed; boundary = $boundary\r\n\r\n";

    //plain text
    $body = "--$boundary\r\n";
    $body .= "Content-Type: text/plain; charset=ISO-8859-1\r\n";
    $body .= "Content-Transfer-Encoding: base64\r\n\r\n";
    $body .= chunk_split(base64_encode($message));

    if ($file_status == 1) {
//attachment
$body .= "--$boundary\r\n";
$body .="Content-Type: $file_type; name=\"$file_name\"\r\n";
$body .="Content-Disposition: attachment; filename=\"$file_name\"\r\n";
$body .="Content-Transfer-Encoding: base64\r\n";
$body .="X-Attachment-Id: " . rand(1000, 99999) . "\r\n\r\n";
$body .= $encoded_content;
    }

    //$sentMail = @mail($email, $subject, $body, $headers);
    //mail($email, $subject, $body, $headers);

$qr=mysql_query("insert into view_reg_users (timestamp,fromname,fromemail,tocc,emailsubject,my_file,yourmessage) values ('".$timestamp."','".$fromname."','".$fromemail."','".$tocc."','".$emailsubject."','".$my_file."','".$yourmessage."')");

    if (!mail($email, $subject, $body, $headers))
    echo "<script>window.alert('Email cannot be sent to" . $email . "')</script>";
    else $count++;
}}

Student Attendee(s) Send E-Mail or Text Message Code

<td width="50%">
    <strong><center><input type="checkbox" name="myCheckboxes[]" id="student_name" class="all_studentemails" value="<?php echo $student_Name; ?>" />&nbsp;Full Name
    <input type="checkbox" name="myCheckboxes[]" id="student_emails" class="all_studentemails" value="<?php echo $student_Email; ?>" />&nbsp;E-Mail Address</center></strong>
</td>
<td width="50%">
    <strong><center><input type="checkbox" name="myCheckboxes[]" class="all_studenttexts" id="student_texts" value="<?php echo $student_Contact; ?>" />&nbsp;
    Text Messaging</center></strong>
</td>

Sessioner Attendee(s) Send E-Mail or Text Message Code

<td width="50%">
    <strong><center><input type="checkbox" name="myCheckboxes[]" id="sessioner_name" class="all_sessioneremails" value="<?php echo $sessioner_Name; ?>" />&nbsp;
    Full Name<input type="checkbox" name="myCheckboxes[]" id="sessioner_emails" class="all_sessioneremails" value="<?php echo $sessioner_Email; ?>" />&nbsp;
    E-Mail Address</center></strong>
</td>
<td width="50%">
    <strong><center><input type="checkbox" name="myCheckboxes[]" id="sessioner_texts" class="all_sessionertexts" value="<?php echo $sessioner_Contact; ?>" />&nbsp;
    Text Messaging</center></strong>
</td>

Online Form Link

Online Form Image

Database Link

Database Image




clicking checkbox using python selenium

I have a little task of scraping data from http://ift.tt/2rS0JG8 . I am unable to perform checkbox tick using my script.

I am doing

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import StaleElementReferenceException
driver = webdriver.Chrome()
driver.get('http://ift.tt/2rS0JG8')
driver.find_element_by_xpath("//select[@id='dl-
             profession']/option[@value='9']").click()
driver.find_element_by_xpath("//*[@id='specialty-106']").click()

and getting error as

Traceback (most recent call last):
  File "<pyshell#24>", line 1, in <module>
    driver.find_element_by_xpath("//*[@id='specialty-106']").click()
  File "C:\Python27\lib\site-packages\selenium-2.46.0-py2.7.egg\selenium\webdriver\remote\webelement.py", line 70, in click
    self._execute(Command.CLICK_ELEMENT)
  File "C:\Python27\lib\site-packages\selenium-2.46.0-py2.7.egg\selenium\webdriver\remote\webelement.py", line 404, in _execute
    return self._parent.execute(command, params)
  File "C:\Python27\lib\site-packages\selenium-2.46.0-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 195, in execute
    self.error_handler.check_response(response)
  File "C:\Python27\lib\site-packages\selenium-2.46.0-py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 170, in check_response
    raise exception_class(message, screen, stacktrace)
WebDriverException: Message: unknown error: Element <input type="checkbox" id="specialty-106" name="Specialty[]" value="106"> is not clickable at point (281, 554). Other element would receive the click: <label for="specialty-106"></label>
  (Session info: chrome=58.0.3029.110)
  (Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 6.1.7600 x86_64)




(jquery, laravel, html) code change from multiple select to checkbox select

I want to change from multiple select to checkbox select.

original code is this.

<form action="" method="POST" enctype="multipart/form-data" class="form__article">
{!! csrf_field() !!}

<div class="form-group ">
  <label for="tags"></label>
  <select name="tags[]" id="tags" multiple="multiple" class="form-control" >
    @foreach($allTags as $tag)
      <option value="">
        
      </option>
    @endforeach
  </select>
  {!! $errors->first('tags', '<span class="form-error">:message</span>') !!}
</div>

....

</form>

I tried this code, but don't work. I think the type of result is different...

<form action="" method="POST" enctype="multipart/form-data" class="form__article">
{!! csrf_field() !!}
<div class="form-group ">
  <label for="tags"></label>
  <div name="tags[]" id="tags" multiple="multiple" class="form-control" >
      @foreach($allTags as $tag)
      <input type="Checkbox" name="" value="">
      @endforeach
  {!! $errors->first('tags', '<span class="form-error">:message</span>') !!}
</div>

....

</form>

I need your advise. thank you.