I have an HTML checkbox. It uses an onclick javascript event to increment an integer var by 1.
I want to decrement the var by one if the checkbox is then unchecked. How can I do this?
I have an HTML checkbox. It uses an onclick javascript event to increment an integer var by 1.
I want to decrement the var by one if the checkbox is then unchecked. How can I do this?
I am using PHP as a programmation language adapting the MVC architecture. and the Polymer library as a view.
I found some problems particularly when I used some polymer elements in a form.
If I use the paper-radio-button, paper-checkbox or core-dropdown-menu, for example,
.
Someone please help me, I'm trying to used Python 2.7 Tkinker GUI to display the result of 'file.py path' in the text widget but it output in the PyCharm not the GUI text. Secondly is it possible to used the 'path=f' outside the 'def callback().
from Tkinter import *
from tkFileDialog import *
import os
#browse files
def callback():
f = askopenfilename()
path.set(f)
r = os.popen('pdfid.py'+' '+f).read()
print r
#Function
def pdfid():
result = os.popen('pdfid.py'+' '+f).read()
return result
def pdfparser():
result = os.popen('pdf-parser.py'+' '+f).read()
return result
#Run Function
def runSelectedItems():
if v1.get() == 1:
print'Pdfid = True'
else:
print'Pdfid = False'
if v2.get() == 1:
print'Pdf-parser = True'
else:
print'Pdf-parser = False'
#Tools Checkbox
def checkbox():
cf = LabelFrame(root, text="Tools")
cf.pack(side=TOP, anchor=N)
left = Label(cf)
v1 = IntVar()
v2 = IntVar()
C1 = Checkbutton(cf, text = "Tool1", variable = v1, command = pdfid)
C2 = Checkbutton(cf, text ="Tool2", variable = v2, command = pdfparser)
C1.pack(side=LEFT, anchor=W)
C2.pack(side=LEFT, anchor=W)
#Button
def button():
b = Button(root, text='Open', command=callback)
l = Label(root, text='File Path: ')
e = Entry(root, textvariable=path, width=50)
r = Button(root, text='Run', command=runSelectedItems)
b.pack(padx=5, pady=0, side=LEFT, anchor=N)
l.pack(padx=5, pady=0, side=LEFT, anchor=N)
e.pack(padx=5, pady=0, side=LEFT, anchor=N)
r.pack(padx=5, pady=0, side=RIGHT, anchor=N)
#main
root = Tk()
path = StringVar()
result = StringVar()
label=LabelFrame(root, text="Output")
label.pack(side=BOTTOM, anchor=W, fill=BOTH, expand=YES)
text = Text(label)
text.pack(fill=BOTH, expand=YES)
button()
checkbox()
root.mainloop()
$("table#flooring tr").find('td:eq('+checkbox+') input[type="checkbox"]').prop('disabled', true);
This is how I disable a checkbox based on the td it is in the variable checkbox for index is dynamic depending on user input. How would it look if i change it to selecting all checkbox after the current one i tried
$("table#flooring tr").find('td:eq('+checkbox+') input[type="checkbox"]').nextAll().prop('disabled', true);
But it is not disabling the checkbox
Any idea is appreciated
UPDATE
<table id="flooring">
<tr>
<td><strong><p>Flooring</p></strong>
</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>
<hr/>
</td>
<td>
<span>1st Floor</span>
</td>
<td>
<span>2nd Floor</span>
</td>
<td>
<span>3rd Floor</span>
</td>
<td>
<span>4th Floor</span>
</td>
</tr>
<tr>
<td><span>Reinforced Concrete</span>
</td>
<td>
<input type="checkbox" class="floor1st checkboxfloor" name="flooring[]" />
</td>
<td>
<input type="checkbox" class="floor2nd checkboxfloor" name="flooring[]" />
</td>
<td>
<input type="checkbox" class="loor3rd checkboxfloor" name="flooring[]" />
</td>
<td>
<input type="checkbox" class="floor4th checkboxfloor" name="flooring[]" />
</td>
</tr>
<tr>
<td><span>Plain Cement</span>
</td>
<td>
<input type="checkbox" class="floor1st checkboxfloor" name="flooring[]" />
</td>
<td>
<input type="checkbox" class="floor2nd checkboxfloor" name="flooring[]" />
</td>
<td>
<input type="checkbox" class="floor3rd checkboxfloor" name="flooring[]" />
</td>
<td>
<input type="checkbox" class="floor4th checkboxfloor" name="flooring[]" />
</td>
</tr>
<tr>
<td><span>Marble</span>
</td>
<td>
<input type="checkbox" class="floor1st checkboxfloor" name="flooring[]" />
</td>
<td>
<input type="checkbox" class="floor2nd checkboxfloor" name="flooring[]" />
</td>
<td>
<input type="checkbox" class="floor3rd checkboxfloor" name="flooring[]" />
</td>
<td>
<input type="checkbox" class="floor4th checkboxfloor" name="flooring[]" />
</td>
</tr>
<tr>
<td><span>Wood</span>
</td>
<td>
<input type="checkbox" class="floor1st checkboxfloor" name="flooring[]" />
</td>
<td>
<input type="checkbox" class="floor2nd checkboxfloor" name="flooring[]" />
</td>
<td>
<input type="checkbox" class="floor3rd checkboxfloor" name="flooring[]" />
</td>
<td>
<input type="checkbox" class="floor4th checkboxfloor" name="flooring[]" />
</td>
</tr>
<tr>
<td><span>Tiles</span>
</td>
<td>
<input type="checkbox" class="floor1st checkboxfloor" name="flooring[]" />
</td>
<td>
<input type="checkbox" class="floor2nd checkboxfloor" name="flooring[]" />
</td>
<td>
<input type="checkbox" class="floor3rd checkboxfloor" name="flooring[]" />
</td>
<td>
<input type="checkbox" class="floor4th checkboxfloor" name="flooring[]" />
</td>
</tr>
</table>
What is the best way to save the state of checked checkboxes and POST the value of those checkboxes after a page refresh? In this situation I have multiple checkboxes to filter results from a MySQL database. Once a box is checked it updates my query and the results will display. The problem I am having is I am now adding pagination. When a user clicks to go to the next page of results, the checkboxes that were selected unchecks, and the php isn't reading that anything was posted and the query runs without the values of the checkbox included in the query.
How can I save the checked checkboxes and POST those values to my query even after page reload or after a user clicks to go to the next set of pagination results?
Here is html form:
<form id="form" method="post" action="">
<input type="checkbox" name="2kandunder" id="2kandunder" onchange="$('#form').submit();" class="checkbox" id="2kandunder" <?=(isset($_POST['2kandunder'])?' checked':'')?>/>
<input type="checkbox" name="2kto4k" id="2kandunder" class="checkbox" onchange="$('#form').submit();" <?=(isset($_POST['2kto4k'])?' checked':'')?>/>
<input type="checkbox" name="4kandup" id="4kandup" class="checkbox" onchange="$('#form').submit();" <?=(isset($_POST['4kandup'])?' checked':'')?>/>
</form>
And the PHP to post checkbox values into a string and then into a query to filter results.
<?php
if (isset($_POST["2kandunder"])) {
$arguments[] = "AND `2kandunder` = 'yes'";
}
if (isset($_POST["2kto4k"])) {
$arguments[] = "AND `2kto4k` = 'yes'";
}
if (isset($_POST["4kandup"])) {
$arguments[] = "AND 4kandup = 'yes'";
}
if(!empty($arguments)) {
$str = implode($arguments);
}
?>
Is it possible to use sessions for this?
I have created a form and I am looking to get the data the user entered. The javascript I have so far pulls in all the data. But also pulls both radio buttons although only one is checked.
Q1 How do I restrict the loop to not pull in both radio buttons but only the selected one?
Q2 How do I get if the check box is checked or not?
Q3 How do I get the data from a textarea?
Thanks in Advance,
JS
var myNodeList = document.getElementsByName('cf');
var myArray = []; // empty Array
for (var i = 0; i < myNodeList.length; i++) {
var self = myNodeList[i];
myArray.push(self);
}
console.log(myArray)
HTML
<!DOCTYPE html>
<html>
<head>
<title>Contact Me</title>
<link rel="stylesheet" type="text/css" href="contactform_Lab8.css">
</head>
<body>
<form id="contactus">
<fieldset>
<label for="name">Name:</label>
<input id="name" type="text" name="cf" autofocus required>
<label for="email">Email:</label>
<input id="email" type="email" name="cf" required>
<label for="phone">Phone:</label>
<input id="phone" type="tel" name="cf" required>
<label for="status">Status:
<select id="status" name="cf" required>
<option value="client">Client</option>
<option value="partner">Partner</option>
<option value="vendor">Vendor</option>
</select>
</label>
<label for="subscribe">
<input id="subscribe" type="checkbox" name="cf" value="check" checked>
Send me your newsletter</label>
<label for="sales">
<label for="support">
<input id="slsSupport" type="radio" name="cf" value="sales" checked>Sales
<input id="slsSupport" type="radio" name="cf" value="support">Support
</label>
</label>
<label for="msg">Message:</label>
<textarea id="msg" name="cf" rows="10" cols="30" required></textarea>
</fieldset>
<fieldset>
<button type="submit">Send</button>
<button type="reset">Reset</button>
</fieldset>
</form>
<script src="contactform_Lab8.js"></script>
</body>
</html>
I have created a grid view in which there are certain number of rows of text box and checkbox. Now i want on checking the checkbox the text of textbox should be changed from 'A' to 'P'. This is my design View.
<asp:GridView ID="grdData" runat="server" style="Text-align:center;">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" OnCheckedChanged="grdData_SelectedIndexChanged"/>
</ItemTemplate>
<HeaderTemplate>
<asp:CheckBox ID="CheckBox2" runat="server" OnClick="CheckAllEmp(this)"/>
</HeaderTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="Status_Header" runat="server" Text="Status" />
</HeaderTemplate>
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Enabled="false" Text="a"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
This is my Code Behind
protected void chkview_CheckedChanged(object sender, EventArgs e)
{
for (int i = 0; i < grdData.Rows.Count; i++){
CheckBox ck =(CheckBox)grdData.Rows[i].Cells[0].FindControl("CheckBox1");
Label Child_Label =(Label)grdData.Rows[i].Cells[5].FindControl("Child_Label");
if (ck.Checked == true){
Child_Label.Text = "Present";}
else
Child_Label.Text = "Absent";}}