I’ve created a WordPress page that in summary, allows someone to start a hangout session. Once the hangout session is started, the user can copy the hangout URL and paste it into an input box, then click submit. The intent is that the updated link on the page stays around for the next user that opens the page to click and follow to the same hangout.
I’m using the following JS function to update the html portion listed below.
<script type="text/javascript">
function updatelink(){
var userInput = document.getElementById('userInput').value;
var lnk = document.getElementById('lnk');
lnk.href = userInput;
lnk.innerHTML = lnk.href;
}
</script>
Here’s the html that calls the function and get’s updated.
Connect to Hangout Here : <a href="" id=lnk>nothing here yet</a> <br>
<input type='text' id='userInput' value='Enter Hangout Link Here' />
<input type='button' onclick='updatelink()' value='Change Link'/>
This works to update the link on the page to the user’s input. The problem i’m having is that it doesn’t save when you refresh the page. It resets when I need it to stay until it gets updated again.
Any help would be appreciated. I’m a beginner, so the more descriptive the better.
Thanks.
You can create the session of that value & when you want to update that value reset the session.
May this logic work for your issue. so you can get that value in SESSION[‘urlhang’] as it is till you will update it.
I’ve found that it may be best for me to use MySQL to update and store the link in a table.
So far I’ve achieved pulling the lnk from my database using the following code:
The first line is creating a shortcode for wordpress. My html that accesses this php script is as follows:
[connectserver] is the php shortcode reference.
The code I have to update the link in the database is as follows:
The following script is used to submit the new link(user input) to the database through the php shortcode above. (when running the php manually, I can change the lnk='”$atts”‘”); portion to my desired variable ex… lnk=’www.yourwebsite.com'”); and it works properly.) (see the rest of the non-working code below.)
I can’t figure out how to pass the new link via user input to the shortcode. Does anyone have an answer for this?
Thanks for the answer Dipak, but i’m a novice and have no experience with javascript. I looked up starting a session but I think the database option may be a better avenue. If I’m wrong please let me know.
Ken