The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Help me tweak my switch-user script

4 posters

Go down

Help me tweak my switch-user script Empty Help me tweak my switch-user script

Post by Sarah.givemestories January 8th 2018, 8:38 pm

So I'm using this script for a switch-user widget I have in my header, always displayed right below my forum's logo.

Code:
<script type="text/javascript">
        function switch_accounts() {
        jQuery.get(document.getElementById('logout').href, function() {
        jQuery.post('/login', 'login=1&username='+document.getElementById('switch_uname').value+'&password='+document.getElementById('switch_pass').value, function () {
        window.location.reload();
        });
        });
        }
        </script>

Something in that function is making it so that the login only works on my forum's home page. When I click the "switch user" button on any other page, nothing happens.

Can someone who knows this code please tell me how to tweak it so the login works on every page?

Here's my forum:
illustrare.forumotion.com
Sarah.givemestories
Sarah.givemestories
Forumember

Posts : 38
Reputation : 2
Language : English
Location : USA

Back to top Go down

Help me tweak my switch-user script Empty Re: Help me tweak my switch-user script

Post by SLGray January 8th 2018, 8:43 pm

Where did you add this code?


Help me tweak my switch-user script Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51489
Reputation : 3519
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Help me tweak my switch-user script Empty Re: Help me tweak my switch-user script

Post by Sarah.givemestories January 8th 2018, 8:44 pm

overall_header template.
Sarah.givemestories
Sarah.givemestories
Forumember

Posts : 38
Reputation : 2
Language : English
Location : USA

Back to top Go down

Help me tweak my switch-user script Empty Re: Help me tweak my switch-user script

Post by SLGray January 8th 2018, 8:59 pm

Please post your forum's link.


Help me tweak my switch-user script Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51489
Reputation : 3519
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Help me tweak my switch-user script Empty Re: Help me tweak my switch-user script

Post by Sarah.givemestories January 8th 2018, 8:59 pm

Sarah.givemestories
Sarah.givemestories
Forumember

Posts : 38
Reputation : 2
Language : English
Location : USA

Back to top Go down

Help me tweak my switch-user script Empty Re: Help me tweak my switch-user script

Post by SLGray January 8th 2018, 10:14 pm

Could you send me in a PM 2 test accounts to test your code?


Help me tweak my switch-user script Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51489
Reputation : 3519
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Help me tweak my switch-user script Empty Re: Help me tweak my switch-user script

Post by Sarah.givemestories January 9th 2018, 4:55 am

So Gray wasn't able to help. Can someone who really knows coding step in?
Sarah.givemestories
Sarah.givemestories
Forumember

Posts : 38
Reputation : 2
Language : English
Location : USA

Back to top Go down

Help me tweak my switch-user script Empty Re: Help me tweak my switch-user script

Post by skouliki January 9th 2018, 7:23 am

i have this code as a widget 

Code:
  <script type="text/javascript">
        function switch_accounts() {
        jQuery.get(document.getElementById('logout').href, function() {
        jQuery.post('/login', 'login=1&username='+document.getElementById('switch_uname').value+'&password='+document.getElementById('switch_pass').value, function () {
        window.location.reload();
        });
        });
        }
        </script>
        Switch user:<hr />
        <input id="switch_uname" type="text" /><br />
        <input id="switch_pass" type="password" /><br />
        <input type="button" value="Switch user" onclick="switch_accounts();" /> 

Help me tweak my switch-user script Scree169
skouliki
skouliki
Manager
Manager

Female Posts : 15133
Reputation : 1696
Language : English,Greek
Location : Greece

http://iconskouliki.forumgreek.com

Back to top Go down

Help me tweak my switch-user script Empty Re: Help me tweak my switch-user script

Post by Sarah.givemestories January 9th 2018, 8:43 am

Does it switch accounts on every page besides the index?
Sarah.givemestories
Sarah.givemestories
Forumember

Posts : 38
Reputation : 2
Language : English
Location : USA

Back to top Go down

Help me tweak my switch-user script Empty Re: Help me tweak my switch-user script

Post by skouliki January 9th 2018, 8:49 am

i think so i havent use it to test it
skouliki
skouliki
Manager
Manager

Female Posts : 15133
Reputation : 1696
Language : English,Greek
Location : Greece

http://iconskouliki.forumgreek.com

Back to top Go down

Help me tweak my switch-user script Empty Re: Help me tweak my switch-user script

Post by Sarah.givemestories January 9th 2018, 10:57 am

Could you please test it and get back to me?
Sarah.givemestories
Sarah.givemestories
Forumember

Posts : 38
Reputation : 2
Language : English
Location : USA

Back to top Go down

Help me tweak my switch-user script Empty Re: Help me tweak my switch-user script

Post by skouliki January 9th 2018, 12:54 pm

at the moment iam not in a laptop and iam not using it to test it, so better wait for someone else to help you or you could try to test it yourself as a widget (the easiest way)
skouliki
skouliki
Manager
Manager

Female Posts : 15133
Reputation : 1696
Language : English,Greek
Location : Greece

http://iconskouliki.forumgreek.com

Back to top Go down

Help me tweak my switch-user script Empty Re: Help me tweak my switch-user script

Post by Sarah.givemestories January 10th 2018, 9:17 pm

The script is the exact same as mine. It doesn't work. I guess I have to wait until someone can give me another script or help fix mine.
Sarah.givemestories
Sarah.givemestories
Forumember

Posts : 38
Reputation : 2
Language : English
Location : USA

Back to top Go down

Help me tweak my switch-user script Empty Re: Help me tweak my switch-user script

Post by Van-Helsing January 14th 2018, 10:31 pm

Hello,
As it seems your javascript tries to retrieve a null or missing element:

Help me tweak my switch-user script 5-VOy-dqQDSdQNRM0bfqVA

Please check if you have all the necessary elements in HTML. Otherwise you have to modify your javascript to work with your HTML elements.
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Help me tweak my switch-user script Empty Re: Help me tweak my switch-user script

Post by Sarah.givemestories January 16th 2018, 7:30 pm

Van-Helsing wrote:Hello,
As it seems your javascript tries to retrieve a null or missing element:

Help me tweak my switch-user script 5-VOy-dqQDSdQNRM0bfqVA

Please check if you have all the necessary elements in HTML. Otherwise you have to modify your javascript to work with your HTML elements.
 
What do you mean by having all the necessary elements in HTML? How do I do that, exactly?
Sarah.givemestories
Sarah.givemestories
Forumember

Posts : 38
Reputation : 2
Language : English
Location : USA

Back to top Go down

Help me tweak my switch-user script Empty Re: Help me tweak my switch-user script

Post by Van-Helsing January 16th 2018, 9:01 pm

Hello,
One of your templates using the below code:

Code:
<div class="switchuser"><script type="text/javascript">function switch_accounts() {jQuery.get(document.getElementById('logout').href, function() {jQuery.post('/login', 'login=1&username='+document.getElementById('switch_uname').value+'&password='+document.getElementById('switch_pass').value, function () {window.location.reload();});});}</script><input id="switch_uname" size="6" type="text">&nbsp;&nbsp;<input id="switch_pass" size="9" type="password">&nbsp;&nbsp;<input value="Switch Character" onclick="switch_accounts();" type="button"></div>

This code contains some errors because the element'switch_uname' and / or 'switch_pass' elements are missing in your HTML code of template. Probably is the index_body template. For this reason the get.ElementById function returns error.

Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum