Im trying to bootstrap a mulitple choice tickbox for PHP. I have the following code:
<div class="container">
<div class="row">
<div class="col-lg-6">
<div class="input-group">
<span class="input-group-addon">
<form action="catcheck.php" method="post">
<input type="checkbox" name="check_list[]" value="value 1">
<input type="submit" />
</form>
</span>
</div>
</div>
</div>
</div>
But im just getting a normal checkbox, how do I go about changing this to submit to catcheck.php whilst using the bootstrap css?
The below code will work (Hope this is what you needed):
<div class="container">
<div class="row">
<div class="col-lg-6">
<div class="input-group">
<span class="input-group-addon">
<form action="catcheck.php" method="post" role="form">
<label>
<input type="checkbox" name="check_list[]" value="value 1" /> Value 1
</label>
<label>
<input type="checkbox" name="check_list[]" value="value 2" /> Value 2
</label>
<label>
<input type="checkbox" name="check_list[]" value="value 3" /> Value 3
</label>
<label>
<input type="checkbox" name="check_list[]" value="value 4" /> Value 4
</label>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</span>
</div>
</div>
</div>
</div>
In catcheck.php
You can retrieve data as $_POST['check_list'] which will return an array. You can begin from:
echo "<pre>";
print_r($_POST);
echo "</pre>";
EDIT:
The below code will do what you have asked (with doc reference)
<div class="row">
<div class="col-lg-6">
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" name="check_list[]" value="value 1" />
</span>
<input type="text" name="text_value[]" class="form-control" />
</div>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" name="check_list[]" value="value 2" />
</span>
<input type="text" name="text_value[]" class="form-control" />
</div>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" name="check_list[]" value="value 3" />
</span>
<input type="text" name="text_value[]" class="form-control" />
</div>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" name="check_list[]" value="value 4" />
</span>
<input type="text" name="text_value[]" class="form-control" />
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
For alignment consider the following CSS:
.input-group
{
margin-bottom:10px;
}
You can adjust the size of input area by reducing col-lg-6 to col-lg-4 and so on.
Fiddle Demo : http://jsfiddle.net/27LnT/
Related
I am trying to shift my radio button to the right for this certain part for a long time and it still doesn't work, I try using padding and class col-md for it and even check if my tag are closed but it is still not moving to the right. Can anybody help me with this problem? Thanks in advance.
test.blade.php
<div class="form-group">
<label class="col-md-2"><b>Residential Status:</b></label>
<div class="col-md-8">
<input type="radio" name="residential_status" value="Local" required> Local<br>
<input type="radio" name="residential_status" value="Overseas" required> Overseas<br>
</div>
</div>
<div class="form-group">
<div class="editfield1">
<div class="radio">
<div id="chkNRICid1">
<label style="font-weight: bold">Do you have a NRIC?</label> <br/>
<input type="radio" name="NRIC_check" id="nricid1" value="Yes" onclick="document.getElementById('NRIC_check').style.display='block'" required> Yes <br>
<input type="radio" name="NRIC_check" id="nricid2" value="No" onclick="document.getElementById('NRIC_check').style.display='none'" required> No
</div>
</div>
</div>
<div class="editfield1" id="NRIC_check" style="display:none">
<label for="NRIC_check"> Type your NRIC/FIN number:</label>
<label><input type="text" name="nric_number1" id="nric_number1"> </label>
</div>
</div>
This is the screenshot of what is happening: (I want it to be like the Residential Status)
So many wayward and un-needed divs you can get rid of along with fixing your nesting, after that it's just a matter of following the structure in the first part of your template:
<div class="form-group">
<div class="col-md-2">
<label>Residential Status</label>
</div>
<div class="col-md-10">
<label><input type="radio" name="residential_status" value="Local" required> Local</label>
<br />
<label><input type="radio" name="residential_status" value="Overseas" required> Overseas</label>
</div>
</div>
<div class="form-group">
<div class="col-md-2">
<label>Do you have a NRIC?</label>
</div>
<div class="col-md-10">
<label><input type="radio" name="NRIC_check" id="nricid1" value="Yes" onclick="document.getElementById('NRIC_check').style.display='block'" required>Yes</label>
<br />
<label><input type="radio" name="NRIC_check" id="nricid2" value="No" onclick="document.getElementById('NRIC_check').style.display='none'" required> No </label>
</div>
</div>
<div class="form-group" id="NRIC_check" style="display:none">
<div class="col-md-2">
<label>Type your NRIC/FIN number:</label>
</div>
<div class="col-md-10">
<input type="text" name="nric_number1" id="nric_number1" />
</div>
</div>
Wrap the two inputs inside a <div> and add some margin.
<div style="margin-left: 50px">
<input ... />
<input ... />
</div>
If you are using Bootstrap 4 you could even:
<div class="ml-5">
I want to extract just the paragraphs in each .pertanyaan class, before the .listjawaban class using DomCrawler/Goutte Symfony component
Is there any way to do this?
I'm coming with $crawler->filter('.pertanyaan p')->eq($i)->html() but it just gives me the first paragraph, because $i is the n-th position of .pertanyaan class.
<div class="pertanyaan"><p></p>
<p>Karena mengalami mutasi, kromosom mengalami perubahan seperti pada gambar di bawah.</p>
<p><img src="http://indocademy.com/images/ipa_2013_133/53_1.png" alt=""><br>Jenis mutasi tersebut adalah ....</p>
<p></p>
<div class="listjawaban">
<div class="radiojawaban">
<input type="radio" name="answer_dup_758" id="answer_dup_758_A" value="A" style="display:none" disabled=""><input type="radio" name="answer_758" id="answer_758_A" value="A" onclick="showbutton(758);">A.
</div>
<div class="pilihanjawaban">
adisi
</div>
</div>
<div class="listjawaban">
<div class="radiojawaban">
<input type="radio" name="answer_dup_758" id="answer_dup_758_B" value="B" style="display:none" disabled=""><input type="radio" name="answer_758" id="answer_758_B" value="B" onclick="showbutton(758);">B.
</div>
<div class="pilihanjawaban">
delesi
</div>
</div>
<div class="listjawaban">
<div class="radiojawaban">
<input type="radio" name="answer_dup_758" id="answer_dup_758_C" value="C" style="display:none" disabled=""><input type="radio" name="answer_758" id="answer_758_C" value="C" onclick="showbutton(758);">C.
</div>
<div class="pilihanjawaban">
inversi
</div>
</div>
<div class="listjawaban">
<div class="radiojawaban">
<input type="radio" name="answer_dup_758" id="answer_dup_758_D" value="D" style="display:none" disabled=""><input type="radio" name="answer_758" id="answer_758_D" value="D" onclick="showbutton(758);">D.
</div>
<div class="pilihanjawaban">
duplikasi
</div>
</div>
<div class="listjawaban">
<div class="radiojawaban">
<input type="radio" name="answer_dup_758" id="answer_dup_758_E" value="E" style="display:none" disabled=""><input type="radio" name="answer_758" id="answer_758_E" value="E" onclick="showbutton(758);">E.
</div>
<div class="pilihanjawaban">
translokasi
</div>
</div>
<div class="buttons">
<input type="button" class="tombol_jawab" id="tombol_jawab_758" value="Jawab" style="display:none" onclick="executejawaban(758,"http://indocademy.com")"><input type="button" class="tombol_clear" id="tombol_clear_758" value="Hapus" style="display:none" onclick="clearjawaban(758)">
</div>
<div class="kunci" id="kunci_758" style="display: none">
<div class="tulisanjawab abu">
<input type="button" id="tombol_kunci" value="+" class="jawaban_758" onclick="showkunci(this)">
Jawaban : <img id="loading_758" src="http://indocademy.com/images/loading.gif" style="height:12px;vertical-align:middle">
<span id="hasil_758"> </span>
</div>
<div class="konten_kunci">
<div class="konten_jawaban_758" id="isi_jawaban"></div>
</div>
</div>
</div>
This is the url I want to crawl: http://indocademy.com/soal/sbmptn/biologi/2013
Everything goes fine except when crawling but at number #53 since there are three paragraph tags to extract (I only assumed each number has its first paragraph tag being the question, and I don't know how to extract all the paragraphs before .listjawaban class)
Please help
Since the page at the URL doesn't have the structure and the class .pertanyaan does not exist, I copied the HTML snippet into a script and used the DomCrawler to get the four elements.
#!/usr/bin/php
<?php
require ('vendor/autoload.php');
use Symfony\Component\DomCrawler\Crawler;
$html = <<<'HTML'
<div class="pertanyaan">
<p></p>
<p>Karena mengalami mutasi, kromosom mengalami perubahan seperti pada gambar di bawah.</p>
<p><img src="http://indocademy.com/images/ipa_2013_133/53_1.png" alt=""><br>Jenis mutasi tersebut adalah ....</p>
<p></p>
<div class="listjawaban">
<div class="radiojawaban">
<input type="radio" name="answer_dup_758" id="answer_dup_758_A" value="A" style="display:none" disabled="">
<input type="radio" name="answer_758" id="answer_758_A" value="A" onclick="showbutton(758);">A.
</div>
<div class="pilihanjawaban">
adisi
</div>
</div>
<div class="listjawaban">
<div class="radiojawaban">
<input type="radio" name="answer_dup_758" id="answer_dup_758_B" value="B" style="display:none" disabled="">
<input type="radio" name="answer_758" id="answer_758_B" value="B" onclick="showbutton(758);">B.
</div>
<div class="pilihanjawaban">
delesi
</div>
</div>
<div class="listjawaban">
<div class="radiojawaban">
<input type="radio" name="answer_dup_758" id="answer_dup_758_C" value="C" style="display:none" disabled="">
<input type="radio" name="answer_758" id="answer_758_C" value="C" onclick="showbutton(758);">C.
</div>
<div class="pilihanjawaban">
inversi
</div>
</div>
<div class="listjawaban">
<div class="radiojawaban">
<input type="radio" name="answer_dup_758" id="answer_dup_758_D" value="D" style="display:none" disabled="">
<input type="radio" name="answer_758" id="answer_758_D" value="D" onclick="showbutton(758);">D.
</div>
<div class="pilihanjawaban">
duplikasi
</div>
</div>
<div class="listjawaban">
<div class="radiojawaban">
<input type="radio" name="answer_dup_758" id="answer_dup_758_E" value="E" style="display:none" disabled="">
<input type="radio" name="answer_758" id="answer_758_E" value="E" onclick="showbutton(758);">E.
</div>
<div class="pilihanjawaban">
translokasi
</div>
</div>
<div class="buttons">
<input type="button" class="tombol_jawab" id="tombol_jawab_758" value="Jawab" style="display:none" onclick="executejawaban(758,"http://indocademy.com")"><input type="button" class="tombol_clear" id="tombol_clear_758" value="Hapus" style="display:none"
onclick="clearjawaban(758)">
</div>
<div class="kunci" id="kunci_758" style="display: none">
<div class="tulisanjawab abu">
<input type="button" id="tombol_kunci" value="+" class="jawaban_758" onclick="showkunci(this)"> Jawaban : <img id="loading_758" src="http://indocademy.com/images/loading.gif" style="height:12px;vertical-align:middle">
<span id="hasil_758"> </span>
</div>
<div class="konten_kunci">
<div class="konten_jawaban_758" id="isi_jawaban"></div>
</div>
</div>
</div>
HTML;
$crawler = new Crawler($html);
$output = $crawler->filter('.pertanyaan p')->each(function ($node) {
return $node->html();
});
print_r($output);
The function each() returns an array of the four paragraphs. The resulting array is here:
Array
(
[0] =>
[1] => Karena mengalami mutasi, kromosom mengalami perubahan seperti pada gambar di bawah.
[2] => <img src="http://indocademy.com/images/ipa_2013_133/53_1.png" alt=""><br>Jenis mutasi tersebut adalah ....
[3] =>
)
If I click on one check box another check box also checked.
addquiz.php
<?php
$unique_id = time().'_'.uniqid(true);
$userid = $this->session->userdata('cp_userid');
?>
<!-- DC QUIZZ -->
<form class="addquizform" id="quiz_form_<?php echo $unique_id;?>" data-form = "<?php echo $unique_id;?>" data-user = '<?php echo $userid ?>'>
<input type="hidden" name="sid" value="<?php echo $sectionId;?>">
<input type="hidden" name="cid" value="<?php echo $courseId;?>">
<div class="dc-quizz-info dc-course-item">
<div class="dc-content-title">
<h5 class="xsm black">Quiz : Title of quiz</h5>
<div class="course-region-tool">
<input type="button" value = "Save" class="mc-btn-3 btn-style-1 savequiz save" id="save_quiz_<?php echo $unique_id;?>">
</div>
</div>
<div class="quizz-body dc-item-body">
<div class="form-item form-checkbox checkbox-style">
<input type="checkbox" id="showanswer" value="1" name="showanswer">
<label for="showanswer">
<i class="icon-checkbox icon md-check-1"></i>
Show Answer
</label>
</div>
<div class="form-item form-checkbox checkbox-style">
<input type="checkbox" id="limittime">
<label for="limittime">
<i class="icon-checkbox icon md-check-1"></i>
Limit time
</label>
</div>
<div class="time">
<div class="form-item">
<input type="text" name="limittime">
<label for="">mins</label>
</div>
</div>
<div class="form-item">
<input type="text" placeholder="Quiz Title" class="fullwidth" name="quiztitle">
</div>
<div class="form-item">
<input type="text" placeholder="Short introduction" class="fullwidth" name="quizintro">
</div>
</div>
</div>
</form>
<!-- END / DC QUIZZ -->
when I go to add one more quiz it asks to check the check box, but when I clicked on check box above check box also checked. How to over come this problem.
Please Check The Name as well as id You Defined there is missing an id and name for checkbox
<div class="dc-quizz-info dc-course-item">
<div class="dc-content-title">
<h5 class="xsm black">Quiz : Title of quiz</h5>
<div class="course-region-tool">
<input type="button" value = "Save" class="mc-btn-3 btn-style-1 savequiz save" id="save_quiz_<?php echo $unique_id;?>">
</div>
</div>
<div class="quizz-body dc-item-body">
<div class="form-item form-checkbox checkbox-style">
<input type="checkbox" id="showanswer" value="1" name="showanswer">
<label for="showanswer">
<i class="icon-checkbox icon md-check-1"></i>
Show Answer
</label>
</div>
<div class="form-item form-checkbox checkbox-style">
<input type="checkbox" name="limitcheck" id="limitcheck">
</div>
<div class="time">
<label for="limittime">
<i class="icon-checkbox icon md-check-1"></i>
Limit time
</label>
<div class="form-item">
<input type="text" value="" id="limittime" name="limittime">
<label for="">mins</label>
</div>
</div>
<div class="form-item">
<input type="text" placeholder="Quiz Title" class="fullwidth" name="quiztitle">
</div>
<div class="form-item">
<input type="text" placeholder="Short introduction" class="fullwidth" name="quizintro">
</div>
</div>
</div>
I'm trying to submit data to a list in my mail chimp but also allow the user to upload a file.
Here is my code, the first chunk is the mailchimp autogenerated form which is submitted via:
<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
and then it's followed by the basic code to submit a file. But at the moment both functions have a submit button. I want only one. Can anyone help?
<body>
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="http://test.us7.list-manage.com/subscribe/post?u=d12b70d4bb1e08c1568d5b392&id=bfb41cbf75" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<h2>Subscribe to our test mailing list</h2>
<div class="indicates-required">
<span class="asterisk">*</span> indicates required
</div>
<div class="mc-field-group">
<label for="mce-EMAIL">
Email Address <span class="asterisk">*</span>
</label>
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
</div>
<div class="mc-field-group">
<label for="mce-FNAME">First Name </label>
<input type="text" value="" name="FNAME" class="" id="mce-FNAME">
</div>
<div class="mc-field-group">
<label for="mce-LNAME">Last Name </label>
<input type="text" value="" name="LNAME" class="" id="mce-LNAME">
</div>
<div class="mc-field-group input-group">
<strong>Interests </strong>
<ul>
<li><input type="checkbox" value="1" name="group[5597][1]" id="mce-group[5597]-5597-0"><label for="mce-group[5597]-5597-0">Interest 1</label></li>
<li><input type="checkbox" value="2" name="group[5597][2]" id="mce-group[5597]-5597-1"> <label for="mce-group[5597]-5597-1">Interest 2</label></li>
<li><input type="checkbox" value="4" name="group[5597][4]" id="mce-group[5597]-5597-2"><label for="mce-group[5597]-5597-2">Interest 3</label></li>
</ul>
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div>
</div>
<form action="upload_file.php" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
<div class="clear">
<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
</div>
</form>
</form>
</body>
You could accomplish this by routing the MailChimp information through your upload_file.php file.
MailChimp has a great API that you can use for more than just adding a subscriber to a list. You would specifically want the listSubscribe() function. There are some great examples on that page.
Here's more documentation on MailChimp's API: http://apidocs.mailchimp.com/api/2.0/
So in your HTML, you would want to remove the second submit button and make it one form with action="upload_file.php". The PHP file would upload the file, then use the API to submit the data to MailChimp.
You html should look like this:
<body>
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="upload_file.php" method="post" enctype="multipart/form-data">
<h2>Subscribe to our test mailing list</h2>
<div class="indicates-required">
<span class="asterisk">*</span> indicates required
</div>
<div class="mc-field-group">
<label for="mce-EMAIL">
Email Address <span class="asterisk">*</span>
</label>
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
</div>
<div class="mc-field-group">
<label for="mce-FNAME">First Name </label>
<input type="text" value="" name="FNAME" class="" id="mce-FNAME">
</div>
<div class="mc-field-group">
<label for="mce-LNAME">Last Name </label>
<input type="text" value="" name="LNAME" class="" id="mce-LNAME">
</div>
<div class="mc-field-group input-group">
<strong>Interests </strong>
<ul>
<li><input type="checkbox" value="1" name="group[5597][1]" id="mce-group[5597]-5597-0"><label for="mce-group[5597]-5597-0">Interest 1</label></li>
<li><input type="checkbox" value="2" name="group[5597][2]" id="mce-group[5597]-5597-1"> <label for="mce-group[5597]-5597-1">Interest 2</label></li>
<li><input type="checkbox" value="4" name="group[5597][4]" id="mce-group[5597]-5597-2"><label for="mce-group[5597]-5597-2">Interest 3</label></li>
</ul>
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div>
</div>
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<div class="clear">
<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
</div>
</body>
I have the following form code but I cannot choose between these for choices.
I can't figure where is the problem. all i know about radio buttons is that they need to have the same name
<div class="controls">
<input type="radio" name="pub_place" id="1" value="1" >1
<input type="radio" name="pub_place" id="2" value="2" >2
<input type="radio" name="pub_place" id="3" value="3" >3
<input type="radio" name="pub_place" id="4" value="3" >4
</div>
this is all the view
<form class="form-horizontal" action="{{ url('/save-publicity')}}" method="post" enctype="multipart/form-data">
{{ csrf_field() }}
<fieldset>
<div class="control-group">
<label class="control-label" for="date01">Publicity Name</label>
<div class="controls">
<input type="text" class="input-xlarge" name="pub_name" required="">
</div>
</div>
<div class="control-group">
<label class="control-label" for="date01">website Link</label>
<div class="controls">
<input type="text" class="input-xlarge" name="pub_link" required="">
</div>
</div>
<div class="control-group">
<label class="control-label" for="fileInput">Publicity Image</label>
<div class="controls">
<input class="input-file uniform_on" name="pub_image" id="pub_image" type="file" required="">
</div>
</div>
<div class="control-group hidden-phone">
<label class="control-label" for="textarea2">Publication status </label>
<div class="controls">
<input type="checkbox" name="pub_status" value="1">
</div>
</div>
<div class="control-group hidden-phone">
<label class="control-label" for="textarea2">Pub Place </label>
<div class="controls">
<input type="radio" name="pub_place" id="1" value="1" >1
<input type="radio" name="pub_place" id="2" value="2" >2
<input type="radio" name="pub_place" id="3" value="3" >3
<input type="radio" name="pub_place" id="4" value="4" >4
</div>
<p>NB: <strong>Place 1 dimension:</strong> 1170x150 |
<strong>Place 2 dimension:</strong> 850x100 |
<strong>Place 3 and 4 dimension:</strong> 270x329</p>
<img style="width:300px"src="backend/brunch.jpg" alt="" />
<div class="form-actions">
<button type="submit" class="btn btn-primary">Add Publicity</button>
<button type="reset" class="btn">Cancel</button>
</div>
</div>
</fieldset>
</form>
they keep giving me NULL on the column pub_place on my database