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/
Related
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.
I have a webpage with multiple questions which is being loaded from my database. Each question has a radio-box because users have to choose an answer from the value of 1 to 5.
Every time I hit the hit the submit button, it goes to a page with the link address showing the users answers (i.e. submit.php?12=1&14=2&15=3&16=4&17=5)
The first value representing the questionID and the second value is the score for that specific questionID.
How do I insert those in my database? I want to insert the questionID and the answer to a table which has a question field and an answer field.
<form action="../process/submit.php" >
<?php
$pin=$_SESSION['pin'];
$question = mysql_query("SELECT question.question, question.questionID FROM question");
$index=0;
while($row=mysql_fetch_array($question)){
?>
<div id="qpanel"><?=$row['question']?>
<div style="float:right;">
<div id="ratingbox" style="vertical-align:middle;">
<label>
<input type="radio" name="<?=$row['questionID']?>" value="1" >
<div id="img1" title="Poor">1</div>
</label>
<label>
<input type="radio" name="<?=$row['questionID']?>" value="2">
<div id="img1" title="Average">2</div>
</label>
<label>
<input type="radio" name="<?=$row['questionID']?>" value="3" >
<div id="img1" title="Good">3</div>
</label>
<label>
<input type="radio" name="<?=$row['questionID']?>" value="4" >
<div id="img1" title="Very Good">4</div>
</label>
<label>
<input type="radio" name="<?=$row['questionID']?>" value="5" >
<div id="img1" title="Excellent">5</div>
</label>
</div>
</div>
</form>
Use name field in this format:
<label>
<input type="radio" name="questionID[<?=$row['questionID']?>][]" value="5" >
<div id="img1" title="Excellent">5</div>
</label>
You will return in POST array with questionID and selected elements.
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
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.
I have a database with pictures that i can delete from or use them in different parts of the the website by choosing one of the radio buttons in the popup.Problem is everytime I click I click on a picture the name of the first picture in the database comes up not the one from the picture i clicked . What's wrong? I used PHP 5.3 and HeidiSQL
<?php
// ...
$result=mysql_query("SELECT * FROM imagini WHERE menu_id=6");
while($data=mysql_fetch_row($result)){ ?>
<div class="tag">
<div id='container_poze_originale'>
Alege alt rol
<div id="my_popup" style="display:none;border:1px dotted gray;padding:.3em;background-color:white;position:absolute;width:auto;left:100px;top:100px">
close
<form action="popup.php" method="post" >
<input type="text" name="alt-rol" value="<?php echo $data[1];?>" /> //always returns the name of the first picture in the database not the one i select
<input type="submit" value="Adauga imagine" class="buton_imagine" />
<div class="radio">
<input type="radio" name="tip_imagine" value="0"/><label for="tip_imagine" class="radio2">Logo</label>
<input type="radio" name="tip_imagine" value="1"/><label for="tip_imagine" class="radio2">Slider</label>
<input type="radio" name="tip_imagine" value="2"/><label for="tip_imagine" class="radio2">Hot destinations</label>
<input type="radio" name="tip_imagine" value="3"/><label for="tip_imagine" class="radio2">Pachete</label>
<input type="radio" name="tip_imagine" value="4"/><label for="tip_imagine" class="radio2">Reclama</label>
<input type="radio" name="tip_imagine" value="5"/><label for="tip_imagine" class="radio2">Background</label>
</div>
</form>
</div>
<div class="imagine_originala">
<img src= "../upload/original/<?php echo $data[1];?>" /></a>
</div>
<div class="Btag" style="display:none;">
<div id="buton_slide4" >
Sterge</td>
</div>
</div>
</div>
</div>
<?php
}
?>
I think I understand your question. You are clicking on
Alege alt rol
and you are surprised that the same <div> always appears?
Well, it is simply because an id should be unique. And if you cycle through your images you create a new <div> each time with the same id: my_popup. When clicking on the link (no matter which one), JavaScript will then just take the first <div> it finds with the id my_popup. So you should just assign an unique id to each div so your JavaScript knows which one to open. You could do this by appending your image id to the div id (assuming you have a unique image id in $data[1]).
So change it to (shortened):
<? while($data=mysql_fetch_row($result)) { ?>
<div class="tag">
<div id="container_poze_originale">
Alege alt rol
<div id="my_popup<?=$data[1]?>" style="display:none;border:1px dotted gray;padding:.3em;background-color:white;position:absolute;width:auto;left:100px;top:100px">
...
</div>
</div>
</div>
<? } ?>
Oh and it might be good to put all those huge inline CSS attributes into an external stylesheet, so it will be easier to maintain/change your webpage later on. And it makes things a bit more readable... :-)
I think your form is ok when you click on the radio but not when you click on the label.
The for attribute of the label need an ID as reference like this :
<input type="radio" name="tip_imagine" value="0" id="tip0" /><label for="tip0" class="radio2">Logo</label>
<input type="radio" name="tip_imagine" value="1" id="tip1"/><label for="tip1" class="radio2">Slider</label>
<input type="radio" name="tip_imagine" value="2" id="tip2"/><label for="tip2" class="radio2">Hot destinations</label>
<input type="radio" name="tip_imagine" value="3" id="tip3"/><label for="tip3" class="radio2">Pachete</label>
<input type="radio" name="tip_imagine" value="4" id="tip4"/><label for="tip4" class="radio2">Reclama</label>
<input type="radio" name="tip_imagine" value="5" id="tip5"/><label for="tip5" class="radio2">Background</label>
With your actual code, the FOR is always the same so you get always the first.