Text for checkboxes not appearing in Drupal 6 - php

This is a Drupal 6 build, I'm trying to figure out why the checkboxes are not showing text. Here's an image of what's going on - you can see that the checkboxes are empty.
The actual generated code is as follows:
<div id="attach-wrapper"><div id="edit-files-392-description-wrapper" class="form-item">
<input type="text" class="form-text" value="2011 SchoolAgePQA_Sample_Items.pdf" size="60" id="edit-files-392-description" name="files[392][description]" maxlength="256">
<div class="description"><small>http://domain.org/sites/domain.org/files/2011 SchoolAgePQA_Sample_Items.pdf</small></div>
</div>
492.94 KB<div id="edit-files-392-remove-wrapper" class="form-item">
<input type="checkbox" class="form-checkbox" value="1" id="edit-files-392-remove" name="files[392][remove]">
</div>
<div id="edit-files-392-list-wrapper" class="form-item">
<input type="checkbox" class="form-checkbox" value="1" id="edit-files-392-list" name="cats">
</div>
<div id="edit-files-392-weight-wrapper" class="form-item">
<select id="edit-files-392-weight" class="form-select" name="files[392][weight]"><option value="-8">-8</option><option value="-7">-7</option><option value="-6">-6</option><option value="-5">-5</option><option value="-4">-4</option><option value="-3">-3</option><option value="-2">-2</option><option value="-1">-1</option><option selected="selected" value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option></select>
</div>
<div id="edit-files-392-private-wrapper" class="form-item">
<input type="checkbox" class="form-checkbox" value="1" id="edit-files-392-private" name="files[392][private]">
</div>
The only thing that sticks out to me is that the value of the checkboxes is exactly the same as the name - and those are all various positive and negative integers.
I've never seen this before, and I'm not sure what might cause it - incorrect configuration setting, poorly coded theme, something else?

There's no label there, so no text is going to be displayed. In drupal it should allow you to change the label and set a value.
The output code should look similar to
<label><input type="checkbox" class="form-checkbox" value="1" id="edit-files-392-list" name="cats">Cats</label>

Try to add label or simply text after your checkbox:
<div id="edit-files-392-list-wrapper" class="form-item">
<label> Text here
<input type="checkbox" class="form-checkbox" value="1" id="edit-files-392-list" name="cats">
</label>
</div>
Or simply :
<div id="edit-files-392-list-wrapper" class="form-item">
<input type="checkbox" class="form-checkbox" value="1" id="edit-files-392-list" name="cats">
Text here
</div>
But i recommande the first solution.

Related

Add Multiple Choice Questions to PHP Web Form

I have a standard PHP web form with text fields, dropdowns, and radio buttons. When the form is submitted, the submitted information is e-mailed to me. I want to add a multiple choice question with checkboxes. I can produce the form field, but I can't figure out how to include multiple selections for that one question on the e-mail that gets sent when the form is submitted. Ideally, I would like to have the multiple selections on one line and separated by semi-colons (or commas if that's easier)
I've included what I think are the relevant parts of the code. Apologies if I didn't format this post correctly.
<form action="example.php" method="post" autocomplete="off">
<div class="form-row">
<label for="first">
<span>First Name:</span>
<input type="text" id="first" name="first" autocomplete="off" list="autocompleteOff">
</label>
</div>
<div class="form-row">
<label for="last">
<span>Last Name:</span>
<input type="text" id="last" name="last" autocomplete="off" list="autocompleteOff">
</label>
</div>
<div class="form-row">
<label for="email">
<span>E-mail:</span>
<input type="text" id="email" name="email" autocomplete="off" list="autocompleteOff">
</label>
</div>
<div class="form-row-multiple">
<label for="multiple">
<span>Choose all that apply:</span><br>
<input type="checkbox" name="multiple" id="multiple" value="Option 1"><span>Option 1</span>
<input type="checkbox" name="multiple" id="multiple" value="Option 2"><span>Option 2</span>
<input type="checkbox" name="multiple" id="multiple" value="Option 3"><span>Option 3</span>
<input type="checkbox" name="multiple" id="multiple" value="Option 4"><span>Option 4</span> </label>
</div>
<div class="form-row">
<button type="submit" name="submit" id="submit"><b>Submit</b></button>
</div>
</form>
<?php
$first = remove_headers($_POST['first']);
$last = remove_headers($_POST['last']);
$email = remove_headers($_POST['email']);
$multiple = remove_headers($_POST['multiple']);
$message =
"First: $first\n\n" .
"Last: $last\n\n"
"E-mail: $email\n\n"
"Multiple: $multiple\n\n"
Two things to do here,
For multiple checkboxes use the name attribute as an array and remove the id attribute, as an HTML page should have a unique ID throughout.
<input type="checkbox" name="multiple[]" value="Option 1"><span>Option 1</span>
<input type="checkbox" name="multiple[]" value="Option 2"><span>Option 2</span>
<input type="checkbox" name="multiple[]" value="Option 3"><span>Option 3</span>
<input type="checkbox" name="multiple[]" value="Option 4"><span>Option 4</span>
When the form is submitted, multi-valued checkboxes are received as an array. So, we can make it semicolon-separated using the implode() function.
$multiple = implode(';', $_POST['multiple']);

Bootstrap radio button already checked not worked

This is my code of radio button i want image radio buttton is alredy check but it's not working
<div class="col-md-4" style="padding-top: 24px;" >
<label>Visual</label>
<div>
<label class="radio-inline">
<input type="radio" value="image" checked="checked" name="media_option[]" class="media_option" autocomplete="off"><?php echo __('Image') ?>
</label>
<label>or</label>
<label class="radio-inline">
<input value="video" type="radio" name="media_option[]" class="media_option" autocomplete="off" ><?php echo __('Video') ?>
</label>
</div>
Try this.
Don't set radio name as array and not need to set autocomplete attribute.
<div class="col-md-4" style="padding-top: 24px;" >
<label>Visual</label>
<div>
<label class="radio-inline">
<input type="radio" value="image" name="media_option" class="media_option" checked="checked" ><?php echo __('Image') ?>
</label>
<label>or</label>
<label class="radio-inline">
<input value="video" type="radio" name="media_option" class="media_option" ><?php echo __('Video') ?>
</label>
</div>
Its working fine, check here:
<input type="radio" value="image" checked="checked" name="media_option[]" class="media_option" autocomplete="off">One
<input type="radio" value="image" checked="checked" name="media_option[]" class="media_option" autocomplete="off">Two
when you are using radio, only one radio can be selected within one group (having same name). The same is working here.
How about this?
This will always work
<input type="radio" value="image" checked="checked" name="media_option[]" class="media_option" autocomplete="off">
If not try this
<input checked type="radio" value="image" name="media_option[]" class="media_option" autocomplete="off">
Just change the checked="checked" to checked only :
Here is the code ,please try:
<div class="col-md-4" style="padding-top: 24px;" >
<label>Visual</label>
<div>
<label class="radio-inline">
<input type="radio" value="image" checked name="media_option[]" class="media_option" autocomplete="off"><?php echo __('Image') ?>
</label>
<label>or</label>
<label class="radio-inline">
<input value="video" type="radio" name="media_option[]" class="media_option" autocomplete="off" ><?php echo __('Video') ?>
</label>
/div>
I came here because I had the same issue and without seeing the rest of the code in the question, won't make any assumptions.
However, if the code above wasn't within a form element, that could have caused the issue.
That was the issue in my case, after placing the radio elements within the form, the checked attribute worked again as expected. Hopefully this helps someone else out as well.

PHP - Getting Multiple Radio Buttons Values from From Submission

I am a newbie in PHP. I have a form like below:
<div class="col-xs-2 col-xs-offset-1">
<input id="radio-ge-1" class="radio-custom" name="radio-ge" type="radio" value="1" checked>
<label for="radio-ge-1" class="radio-custom-label tooltips">1 <span>Impossible to get marks</span></label>
</div>
<div class="col-xs-2">
<input id="radio-ge-2" class="radio-custom" name="radio-ge" value="2" type="radio">
<label for="radio-ge-2" class="radio-custom-label tooltips">2 <span>You have to work hard to get marks</span></label>
</div>
<div class="col-xs-2">
<input id="radio-ge-3" class="radio-custom" name="radio-ge" value="3" type="radio">
<label for="radio-ge-3" class="radio-custom-label tooltips">3 <span>The usual, just like any other class</span></label>
</div>
<div class="col-xs-2 col-xs-offset-1">
<input id="radio-sl-1" class="radio-custom" name="radio-sl" value="1" type="radio" checked>
<label for="radio-sl-1" class="radio-custom-label tooltips">1 <span>Unbearable pressure</span></label>
</div>
<div class="col-xs-2">
<input id="radio-sl-2" class="radio-custom" name="radio-sl" value="2" type="radio">
<label for="radio-sl-2" class="radio-custom-label tooltips">2 <span>High pressure, But doable</span></label>
</div>
<div class="col-xs-2">
<input id="radio-sl-3" class="radio-custom" name="radio-sl" value="3" type="radio">
<label for="radio-sl-3" class="radio-custom-label tooltips">3 <span>Fair, just like any other class</span></label>
</div>
I'm trying to save both radio buttons value in PHP by using the code:
$g_Easiness = $_POST['radio-ge'];
$s_Load = $_POST['radio-sl'];
But in this case, I'me only getting the first button's value. Second button's value = on.
I have spend more than two hours to figure it out. But cannot resolve it. Can anyone please help me to solve the problem?
Please use below code for radio buttons
if input type="radio" then it should give value="" otherwise in value it will show "on"
e.g.
<input id="radio-must" class="radio-custom" name="radio-nns" value="absolutely" type="radio" checked>
output = [radio-nns] => on
instead put ( you can see value="1")
<input id="radio-must" class="radio-custom" name="radio-nns" value="absolutely" type="radio" checked value="1">
output = [radio-nns] =>1

radio button "Checked" option not working

Could you please help me why my checked option in the following code is not working?
<div class="span1">
<h7> Sex</h7>
<label class="radio">
<input id="pccf_sexMF" name="pccf_sexMF" value="M" type="radio" checked class="span1" > M
</label>
<label class="radio">
<input id="sexMF" name="pccf_sexMF" value="F" type="radio" class="span1"> F
</label>
</div>
Thanks
It works on this fiddle
<div class="span1">
Sex
<label class="radio">M</label>
<input id="pccf_sexMF" name="pccf_sexMF" value="M" type="radio" checked="checked" class="span1"/>
<label class="radio">F</label>
<input id="sexMF" name="pccf_sexMF" value="F" type="radio" class="span1"/>
</div>
First - no such thing as h7
Only text should be in a label, not the input
As I said in my comment, you could have another element with position:absolute that will cover your div because its height is bigger than you need it to be. Something like this:
http://jsfiddle.net/hescano/8T7Nc/
To avoid this, you can set your div a relative position:
<div class="span1" style="position:relative">
http://jsfiddle.net/hescano/8T7Nc/1/

html5 form not reacting to submit

I've got a simple one-page form, the kind I've written dozens of times, but this behavior is totally new to me. At first, it was submitting on page-load, thus redirecting automatically to the next page in the series. I'm still not sure how I got that to stop, but now it's not doing anything at all when you hit "submit". The page simply sits there.
I've tried stripping out the error-checking scripts, the show/hide script, even jquery itself, then taking the form down to just one input. I tried getting rid of the redirect and just having it output a simple line, then vardump, and still nothing. I hit submit, and no matter what I do, the page just sits there. I've never run into behavior like this before, and firebug et al give me no errors or leads.
If anyone has any ideas at all, no matter how crazy, I'm willing to try. I'm at a loss. Thanks in advance!
<?php
session_start();
include('functions.php');
if ($_POST['submit']) {
$company = $_POST['company'];
$taxid = $_POST['taxid'];
header("location:step2.php");
}
include('head.php'); ?>
<form method="post" name="basic" action="step1.php">
<div class="col70">
<label for="company">Organization/Business name <img src="img/req.jpg" alt="required"></label>
<input type="text" name="company" id="company" value="" />
</div>
<div class="col30">
<label for="taxid">Taxpayer ID# (IEN or SS#) <img src="img/req.jpg" alt="required"></label>
<input type="text" name="taxid" id="taxid" value="" />
</div>
<div class="newcol">
<label for="address">Mailing Address <img src="img/req.jpg" alt="required"></label>
<input type="text" name="address" id="address" value="" />
</div>
<div class="col30 newcol">
<label for="city">City <img src="img/req.jpg" alt="required"></label>
<input type="text" name="city" id="city" value="" />
</div>
<div class="col30">
<label for="state">State <img src="img/req.jpg" alt="required"></label>
<select name="state" id="state" tabindex="<?php echo $tabin; $tabin++; ?>">
<option value="0"></option>
<option value="1">Alabama</option>
</select>
</div>
<div class="col25">
<label for="zipcode">Zip Code <img src="img/req.jpg" alt="required"></label>
<input type="text" name="zipcode" id="zipcode" value="" />
</div>
<fieldset><legend>1. What kind of group/company do you have? <img src="img/req.jpg" alt="required"></legend>
<span id="nfpfp" class="InputGroup">
<label><input name="nfpfp" id="nfpfp_1" type="radio" value="1" />For-profit business.</label>
<label><input name="nfpfp" id="nfpfp_2" type="radio" value="2" />Non-profit 501(c)3 organization.</label>
</span>
</fieldset>
<fieldset><legend>2. How will you use the booth space? Select all that apply. <img src="img/req.jpg" alt="required"></legend>
<span id="type" class="InputGroup">
<label><input name="food" id="type_1" type="checkbox" value="1" />Food sales</label>
<label><input name="retail" id="type_2" type="checkbox" value="2" />Retail sales</label>
<label><input name="activity" id="type_3" type="checkbox" value="3" />Activity</label>
<label><input name="display" id="type_4" type="checkbox" value="4" />Display</label>
<label><input name="other" id="type_5" type="checkbox" value="5" />Other</label>
</span>
</fieldset>
<label for="otherdetails" class="newcol offsides">Enter a short description of your use. (Ex: "BBQ sandwiches", "kite kits", "face painting".) <img src="img/req.jpg" alt="required"></label>
<input type="text" name="otherdetails" id="otherdetails" value="" />
<fieldset><legend>3. Select any/all that apply. Additional questions may appear, if further information is required.</legend>
<span id="additional" class="InputGroup">
<label><input name="raffle" id="raffle_1" type="checkbox" class="switchcheck1" value="1" />I'll be selling raffle tickets and/or holding a raffle at the festival.</label>
<div class="newcol offstate1">
<label for="raffledetails">You'll need written permission from the Exchange Club. Please enter details about the raffle. <img src="img/req.jpg" alt="required"></label>
<textarea name="raffledetails" id="raffledetails" tabindex="<?php echo $tabin; $tabin++; ?>"></textarea>
</div>
<label><input name="trailer" type="checkbox" id="trailer_1" value="1">I'll be bringing a trailer.</label>
<label><input name="outlets" type="checkbox" id="outlets_1" class="switchcheck2" value="1" />I'll require electrical outlets.</label>
<div class="newcol offstate2">
<label for="outletsdetails">How many outlets will you require? <img src="img/req.jpg" alt="required"></label>
<input type="text" name="outletsdetails" id="outletsdetails" />
</div>
</span>
</fieldset>
<input type="button" name="submit" class="a_button" value="submit" />
</form>
The element with name="submit" is of type button and not submit, so it renders a plain button that does nothing (with the intention that you bind some JavaScript to it).
Use type="submit" instead.
Try
<input type="submit" name="submit" class="a_button" value="submit" />
for your submit button.

Categories