Click to open network menu
Join or Log In
Mobafire logo

Join the leading League of Legends community. Create and share Champion Guides and Builds.

Create an MFN Account






Or

's Forum Avatar

Any webmasters (html/php/sql) here? Help needed.

Creator: Joxuu December 18, 2014 6:00am
Joxuu
<Fabulous>
Joxuu's Forum Avatar
Show more awards
Posts:
4103
Joined:
Apr 7th, 2012
Permalink | Quote | PM | +Rep December 18, 2014 6:00am | Report
Couldn't find a better place to post. I was thinking about making a blog which would've been better as the problem is quite personal but in the other hand, blogs are pretty dead atm.

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.

"A person giving you advice isn't perfect and has their own shortcomings but they may give you the piece that you're missing."
Latest Legend
<Member>
Latest Legend's Forum Avatar
Show more awards
Posts:
3039
Joined:
Dec 7th, 2012
Permalink | Quote | PM | +Rep December 18, 2014 7:37am | Report
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?
********'s a pretty good fertilizer
Joxuu
<Fabulous>
Joxuu's Forum Avatar
Show more awards
Posts:
4103
Joined:
Apr 7th, 2012
Permalink | Quote | PM | +Rep December 18, 2014 7:58am | Report
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

"A person giving you advice isn't perfect and has their own shortcomings but they may give you the piece that you're missing."
Latest Legend
<Member>
Latest Legend's Forum Avatar
Show more awards
Posts:
3039
Joined:
Dec 7th, 2012
Permalink | Quote | PM | +Rep December 18, 2014 10:11am | Report
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:
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>
Other way to find the element (supposedly previousElementSibling isn't supported very well(?))
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
Joxuu
<Fabulous>
Joxuu's Forum Avatar
Show more awards
Posts:
4103
Joined:
Apr 7th, 2012
Permalink | Quote | PM | +Rep December 18, 2014 11:33am | Report
It's a little bit more complicated. I can send you the details through pm if you are up for the challenge.

"A person giving you advice isn't perfect and has their own shortcomings but they may give you the piece that you're missing."
Latest Legend
<Member>
Latest Legend's Forum Avatar
Show more awards
Posts:
3039
Joined:
Dec 7th, 2012
Permalink | Quote | PM | +Rep December 18, 2014 11:41am | Report
Well, like I said, it's not really my thing. I would like to try though.
********'s a pretty good fertilizer

You need to log in before commenting.

League of Legends Champions:

Teamfight Tactics Guide