Skip to content
← Back to Community
How Would I Make JS dynamically generate a link in repl,s editor?
Profile icon
webmunchster

So in one of the websites I am developing (read: attempting to develop), you can create an article using JavaScript. So if a user wanted to create an article after the form, the JavaScript would generate a page using variables from the form. Then there is the problem of searching and (dynamically?) adding them to a list of articles. How would I do this?

Answered by heyitsmarcus [earned 5 cycles]
View Answer
Voters
Profile icon
AzFaRRaZyN
Profile icon
webmunchster
Comments
hotnewtop
Profile icon
heyitsmarcus

The strategy I would go with (if you're only using client side JavaScript) is to have the "pages" be just elements on the page that are styled to take up either the full view of the window (like a normal HTML page would) or whatever view you choose. So, you would create the markdown in HTML for the new "page" then append that to a new "page-like" element that you sort in some order. And when you create the "page-like" element, give it some attribute i.e. if there was an article about modern rappers it might be data-keywords="rap,rapper,rappers,famous rappers" and then aggregate those elements into a list when searching and search through each one finding matches with the keywords listed in their attribute.

If you come up with some code, we can better help you produce a satisfying result.

Profile icon
webmunchster

@heyitsmarcus
OK, thank you! I will try to implement this into my site!

Profile icon
heyitsmarcus

@webmunchster
Sweet! Here in a little bit, I'll make up a little demo so that you have a baseline to go off of for your own code!

Profile icon
webmunchster

@heyitsmarcus
OK, thank you so much!

Profile icon
heyitsmarcus

@webmunchster
Alright man, I made a little repl that shows how to use the keywords I described to you. If you have some questions, just let me know!

https://repl.it/@heyitsmarcus/Search-Dynamic-JavaScript-App

Profile icon
webmunchster

@heyitsmarcus
Thank you so much! I would have never figured this out!

Profile icon
heyitsmarcus

@webmunchster
Not a problem! I hope everything was clear in the comments so that you can use something like that in your code.

Profile icon
webmunchster

@heyitsmarcus
Yes! I was able to implement it into my site! Again, thank you so much!

Profile icon
heyitsmarcus

@webmunchster
Awesome! I'm happy to hear that! If you feel like it and have a Twitter, give me a follow on Twitter, and I can help you as best I can, and I post a lot of developer things, too. https://twitter.com/marcusaparsons

Profile icon
webmunchster