I have a table where I need to find if the checkbox corresponding to a cell is checked or not, see for example, I need to find out if the checkbox id=830 which is a sibling of DeviceHelp is checked or not.
Similarly for element Contact, I will have to check whether checkbox id="72" is checked / unchecked
And I can only rely on the text elements (contact, DeviceHelp, etc) to get the checkboxes state and not the checkbox ids which could change.
<tr class="row active" style="display: table-row;">
<td>
<input id="72" class="rowcheck" type="checkbox" value="true" name="ModesForUi[0].Allow" categoryid="58" disabled="">
<input type="hidden" value="false" name="ModesForUi[0].Allow">
</td>
<td> Administration - Read </td>
<td>
Contact
<input id="ModesForUi_0__ResourceID" type="hidden" value="72" name="ModesForUi[0].ResourceID">
<input id="ModesForUi_0__ModeID" type="hidden" value="12185" name="ModesForUi[0].ModeID">
</td>
<td> Controls access to Search Contacts link and to view contact details page. Navigate to Menu\Advanced\More </td>
</tr>
<tr class="row active" style="display: table-row;">
<td>
<input id="830" class="rowcheck" type="checkbox" value="true" name="ModesForUi[1].Allow" categoryid="58" disabled="">
<input type="hidden" value="false" name="ModesForUi[1].Allow">
</td>
<td> Administration - Read </td>
<td>
DeviceHelp
<input id="ModesForUi_1__ResourceID" type="hidden" value="830" name="ModesForUi[1].ResourceID">
<input id="ModesForUi_1__ModeID" type="hidden" value="12186" name="ModesForUi[1].ModeID">
</td>
<td> Controls access to Help icon displayed next to logout icon and next to the menu. </td>
</tr>
Have tried the following, but I am not getting the checkbox value
"ancestor::td[1]/input[1]/preceding-sibling::td[normalize-space(text())='DeviceHelp']")
And
//tr[position()>1]/td[normalize-space(text())='DeviceHelp*']/parent::td/preceding-sibling::td/input#value
Please xpath experts could you shine some light on what is wrong with the paths above and how to get to the checkbox ?
Thanks!
I think I know what you're trying to get here...
Try this for Device Help:
/root/tr/td[normalize-space(text())='DeviceHelp']/../td[1]/input[1]/#value
And this for Contact:
/root/tr/td[normalize-space(text())='Contact']/../td[1]/input[1]/#value
"root" is just whatever node you're starting from, I added that to test locally, as the XML snippet isn't complete.
EDIT
Try this:
//tr/td[normalize-space(text())='DeviceHelp']/../td[1]/input[1]/#value
//tr/td[normalize-space(text())='Contact']/../td[1]/input[1]/#value
Related
So I have a dynamic table, where you can add as many services as you want, you can select how many of them and if you want to have a discount for each service
<tr v-if="proceduresList.length" v-for="(procedure,index) in proceduresList" :key="procedure.id">
<td>{{ procedure.name }}</td>
<td>
<input v-model="procedure.amount" type="number" step="any" class="form-control">
</td>
<td>
<input v-model="procedure.discount" type="number" step="any" class="form-control">
</td>
<td class="text-center">
<button class="btn btn-danger btn-sm" #click="removeProcedure(procedure)"><i class="fa fa-trash"></i></button>
</td>
</tr>
I have a validation for the procedures array in my laravel backend whick, In case of errors, returns something like this
errors:Object
description:"The description field is required."
procedures.0.amount:"The procedures.0.amount field is required."
procedures.1.discount:"The procedures.1.discount field is required."
procedures.2.amount:"The procedures.2.amount field is required."
procedures.2.discount:"The procedures.2.discount field is required."
start_date:"The start date field is required."
What I want to do is to display the individual errors for each row, I haven't figured out how.
I tried like this
<input v-model="procedure.amount" type="number" step="any" class="form-control">
<span v-if="attentionForm.errors.procedures[index].amount">{{ attentionForm.errors.procedures[index].amount }}</span>
But when I add a service / procedure to the table, the page goes blank and in the debugger it says:
TypeError
Cannot read properties of undefined (reading '0')
You can use square brackets to access the error property:
<span v-if="attentionForm.errors[`procedures.${index}.amount`]">
{{ attentionForm.errors[`procedures.${index}.amount`] }}
</span>
Example here: https://youtu.be/LILSriakRZA?t=547
I am displaying the details of a particular table in my JSP page using a for-each loop in the following manner:
<c:forEach items="${List2}" var="alist">
<tr>
<td>
<input type="checkbox" name="check" value="${alist.check}">
</td>
<td>${alist.two}</td>
<td>${alist.three}</td>
<td>${alist.four}</td>
</tr>
</c:forEach>
<input type="radio" id="agree" value="Agree"/>Agree
<input type="radio" id="disagree" value="Disagree"/> Disagree
<input type="submit" value="Submit"/>
Now, there is no column named "check" in my DB. It is a transient field in my POJO. I do have a Agree/Disagree column in my DB. I want to check particular rows, click "Agree" or "Disagree" and on clicking Submit, the Agree/Disagree column for those records should be updated respectively. I'm using Spring MVC with Hibernate. Please tell me if any more info is required from my side.
You can do this with simple jQuery, Set class(say .chkbox here) to all checkboxes. Whenever any change event happened say,
if checked, the value of checkbox added to JS array.
If unchecked, the value will be removed from JS array.
$(document).ready(function() {
var selectedArray = [];
$('.chkbox').change(function() {
if($(this).is(":checked")) {
selectedArray.push($(this).val());
} else {
selectedArray.pop($(this).val());
}
//alert(selectedArray);
$("#textbox1").val(selectedArray);
});
});
Finally I used textbox to hold all the selected checkboxes value. You can make it into a hidden give a name attribute.
<input type="checkbox" class="chkbox" value="101"> This is 101<br />
<input type="checkbox" class="chkbox" value="102"> This is 102<br />
<input type="checkbox" class="chkbox" value="103"> This is 103<br />
<input type="checkbox" class="chkbox" value="110"> This is 110<br />
<input type="checkbox" class="chkbox" value="111"> This is 111<br />
<input type="checkbox" class="chkbox" value="112"> This is 112
<br />
<input type="hidden" id="textbox1" name="selectedArray" />
Sent it to a controller and split the values by comma (,).
Update :
In your code, you can update like this.
<c:forEach items="${List2}" var="alist">
<tr>
<td>
<input type="checkbox" class="chkbox" name="check" value="${alist.check}">
</td>
<td>${alist.two}</td>
<td>${alist.three}</td>
<td>${alist.four}</td>
</tr>
<input type="hidden" id="textbox1" name="selectedArray" />
</c:forEach>
That's all about required.
See the JS Demo how it works. Hope this helps.
i would like to add a recaptcha to my web form and have been following the instructions on the web but i just can't get the image to display.
i followed these steps:
- downloaded and unzipped the recaptcha folder
- uploaded recaptchalib onto my root folder (server side)
- made an account on recaptcha site
- copied the public and private key to paste into my php code
- i pasted the php code into my html code like this:
<form method="post" name="contact_form" action="contactengine.php">
<table>
<tr>
<td>
<label for="Name">Name </label>
</td>
<td>
<input id="Name" name="Name" type="text" maxlength="300" value=""/ >
</td>
</tr>
<tr>
<td>
<label for="Email">Email </label>
</td>
<td>
<input id="Email" name="Email" type="text" maxlength="300" value=""/ >
</td>
</tr>
<td class="buttons">
<input type="hidden" name="form_id" value="" />
<?php
require_once('recaptchalib.php'); // reCAPTCHA Library
$pubkey = "public-key-here"; // Public API Key
echo recaptcha_get_html($pubkey); // Display reCAPTCHA
?>
<input type="submit" name="submit" value="Submit" class="submit-button" />
</td>
</tr>
</table>
</form>
this should at least display the recaptcha image, but i just cannot get it to display.
i tried making an index.php and pasting my in there, but that doesn't even display a thing.
It should be so simple and yet i must be missing something. It's driving me crazy.
Help will be much appreciated, thanks
B
Are you getting any PHP errors in the log? Check to see if you are able to open a socket. The reCaptcha library must be able to do a fetch server side.
If you can't then enable sockets by adding "allow_url_fopen=On" to your php.ini config file.
I have recently started using bootstrap to create a front end to a website. I was using chrome to develop it originally. I recently started testing on firefox and I ran into a problem. I have a few radio buttons on the front page. When I click on the one I want it looks as if it is only selecting the first one and not the one I am clicking on. If I click quickly a few times it makes the selection properly. Any ideas why this is happening? The code is here :
<form action="redirector.php" action="get">
<fieldset>
<table border="1">
<tr>
<td valign="top"><b>Please select a genome:</b><br>
<label class="radio">
<input type="radio" name ="genome" value="Acral2">Acremonium Alcalophilum<br><input type="radio" name ="genome" value="Aspni3">Aspergillus niger<br><input type="radio" name ="genome" value="Glotr1_1">Gloeophyllum trabeum<br><input type="radio" name ="genome" value="Phchr1">Phanerochaete chrysosporium<br><input type="radio" name ="genome" value="PleosPC15_2">Pleurotus ostreatus<br><input type="radio" name ="genome" value="Spoth2">Sporotrichum Thermophile<br><input type="radio" name ="genome" value="Thite2">Thielavia terrestris<br> </label>
</td>
<td valign="top">
<b>View proteins with JGI annotation of type:</b><br>
<label class="radio">
<input type="radio" name ="jgiAnnotation" value=sigPInformationView>SignalP Information<br>
<input type="radio" name ="jgiAnnotation" value=ecInformationView>EC and Pathway Information<br>
<input type="radio" name ="jgiAnnotation" value=domainInformationView>Domain Information<br>
<input type="radio" name ="jgiAnnotation" value=goInformationView>Go Information<br>
</label>
<button type="submit" class="btn">Submit</button>
</fieldset>
</form>
</td>
<td valign="top">
<form action="annotationInfoView.php" action="get">
<fieldset>
<b>View single protein:</b><br>
Enter our ID number:<input type="text" name ="ourId"><br>
(i.e. jgi_Spoth2_2293939)<br>
<button type="submit" class="btn">Submit</button>
</fieldset>
</form>
</td>
</tr>
</table>
http://jsfiddle.net/CTF2s/
The problem is you have multiple radio buttons inside of a single label.
If I click quickly a few times it makes the selection properly.
This is probably because you're clicking directly on the radio button and not the text next to the radio button. This is how all browsers will behave, including Chrome.
Check out the "Checkboxes and radios" section of Twitter Bootstrap's "Forms" documentation for a working example.
Run into a bit of an odd problem that is increasingly frustrating
Scenario: I have a list of domain objects, each has a g:select attached to it that is rendered by a remote field.
How do I tie the status variable OR the personInstance ID to the selection box, so that when I use the renderField, I update testDiv_(number)
View:
<g:each in="${listOfPeople}" status="i" var="personInstance">
<td>
Text: <g:remoteField action="getResults" controller="person" id="" update="testDiv_${personInstance.id}" paramName="search" name="getResults" value="" />
<g:each in ="${personInstance?.choices}" var="choice" status="x">
<li>${choice}</li>
</g:each>
</td>
<td>
<g:render template="renderThisTemplate"></g:render>
</td>
</g:each>
Template:
<div id="testDiv_${personInstance.id}" class="testDiv_${personInstance.id}">
<g:select id="aChoice" name="aChoice.id" from="${allChoices}" optionKey="id" value="" />
<g:actionSubmit action="addChoice" value="Add"/>
</div>
Edit
I know that the remote call (ajax) is passing the update for testDiv_(number). The problem is with the template ID and assigning that value to the template div.
Just incase anyone needs this answer in the future. Apparently you cannot reference the instance variable (personInstance) in the g:each from the template.
So I replaced the g:render with its code and it worked:
<g:each in="${listOfPeople}" status="i" var="personInstance">
<td>
Text: <g:remoteField action="getResults" controller="person" id="" update="testDiv_${personInstance.id}" paramName="search" name="getResults" value="" />
<g:each in ="${personInstance?.choices}" var="choice" status="x">
<li>${choice}</li>
</g:each>
</td>
<td>
<div id="testDiv_${personInstance.id}" class="testDiv_${personInstance.id}">
<g:select id="aChoice" name="aChoice.id" from="${allChoices}" optionKey="id" value="" />
<g:actionSubmit action="addChoice" value="Add"/>
</div>
</td>
</g:each>