If you could post a short description of what you need help with, what you tried and why it didn't fulfill your needs, I think that would increase the chance of someone jumping in by a great amount.
What's the goal of your project?
What's the goal of your project?
********'s a pretty good fertilizer
I have a search field which shows matched results from a database
img
The button at the end of it ("X") should copy the number at the end when it is pressed and send it to a form field. Currently the problem is it's sending every single number there is instead of recognizing which "X" was pressed and only copying that number.
Here is the field where it should go
img

The button at the end of it ("X") should copy the number at the end when it is pressed and send it to a form field. Currently the problem is it's sending every single number there is instead of recognizing which "X" was pressed and only copying that number.
Here is the field where it should go


"A person giving you advice isn't perfect and has their own shortcomings but they may give you the piece that you're missing."
Disclaimer: I'm not a web developer, I hardly write web languages, my code is hacked together and may separate kittens from their homes. If there's anyone out there using different code it's probably better than this.
Since I don't have your code I just made an example of what I would do (using client-side javascript), assuming a result looks somewhat like the divs in the example:
Other way to find the element (supposedly previousElementSibling isn't supported very well(?))
http://stackoverflow.com/questions/10924086/how-to-get-the-previous-sibling-name
https://developer.mozilla.org/en-US/docs/Web/API/NonDocumentTypeChildNode.previousElementSibling
There are other ways of course, like fiddling with ids or you could try giving the X and textbox a class(like "X" and "input") and play around with getElementsByClassName and decide the right offset by comparing the array of Xs to this, if the Xs and inputs aren't easily connected by some parent element like in my example.
Does this help? Good luck!
Since I don't have your code I just made an example of what I would do (using client-side javascript), assuming a result looks somewhat like the divs in the example:
Code:
<!DOCTYPE html>
<html>
<head>
<script>
function pasteNumber(X)
{
document.getElementById("output").value = X.previousElementSibling.value;
}
</script>
</head>
<body>
<div>
<input>
<button onClick="pasteNumber(this);">X</button>
</div>
<div>
<input>
<button onClick="pasteNumber(this);">X</button>
</div>
<input id="output">
</body>
</html>
Code:
var p = X;
do p = p.previousSibling;
while (p && p.nodeType != 1);
document.getElementById("output").value = p.value;
http://stackoverflow.com/questions/10924086/how-to-get-the-previous-sibling-name
https://developer.mozilla.org/en-US/docs/Web/API/NonDocumentTypeChildNode.previousElementSibling
There are other ways of course, like fiddling with ids or you could try giving the X and textbox a class(like "X" and "input") and play around with getElementsByClassName and decide the right offset by comparing the array of Xs to this, if the Xs and inputs aren't easily connected by some parent element like in my example.
Does this help? Good luck!
********'s a pretty good fertilizer
You need to log in before commenting.
So... I have a small problem (or actually 2) which I have been unable to solve. Couldn't find any help from google either. Anyone here working familiar with programming? Could someone willing to help contact me through PM/Skype, why not even here though. (joxuu or jjoxuu is my skype name). Any kind of help is welcome.