NameSilo

JavaScript is this possible without server side.

Spacemail by SpaceshipSpacemail by Spaceship
Watch

action012

Established Member
Impact
4
What I want to do is take a .js file that has entries like:

passwordlist = new Array(1001)
passwordlist[1] = "49TIIJT"
passwordlist[2] = "JLPBE35"
passwordlist[3] = "JW3O988"
passwordlist[4] = "9GI6XQQ"
passwordlist[5] = "7LS6DVQ"
passwordlist[6] = "KIV8FKL"


And from a form entry when I submit a number to the script it would display the value of the variable. So if I submitted the number 5 it would display 7LS6DVQ.

Can this be done without the use of server side?

Thanks,

Steve
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Javascript is very limited on those types of actions. I believe it can be done. I just havn't got the knowledge of Javascript to do it.

10 times easyer with Server-Side.

iNod.
 
0
•••
iNod said:
Javascript is very limited on those types of actions. I believe it can be done. I just havn't got the knowledge of Javascript to do it.

10 times easyer with Server-Side.

iNod.

Thanks I have very limited knowledge with JavaScript I could do it with eases in PHP but this time I need it to be Client side.

Steve
 
0
•••
Yea, it would be possible :). Im to tired to write the script ATM :hehe:

-Josh
 
0
•••
How would you submit the number to the script?

You can submit by simply calling on the function on the click of the button such as

onclick = "javascript:passListFunction(5)"

and the function will have the code to display the variable.

If you are attempting to submit to another page, its not possible since you have to use server side (you can also use server side javascript by the way).
 
0
•••
JS can do this

Method 1:
Use a cookie

Method 2:
Use the querystring

Method 3:
Use a popup.

I would go with method 3

Here is the js that should do this.
Code:
<Script>
//get the number from the form field and call main function with it
function getNum() {
  var num;
  num = document.form.in.code.value;
  answer(num);
}
//Function to popup a window and write the value of the variable.
function answer(ans)
{
 poph = 100;
 popw = 100;
 var displaypass;
 var myWinWidth = (window.screen.width/2) - (popw/2);
 var myWinHeight = (window.screen.height/2) - ((poph/2) + 50);

passwordlist = new Array(1001);
passwordlist[1] = "49TIIJT";
passwordlist[2] = "JLPBE35";
passwordlist[3] = "JW3O988";
passwordlist[4] = "9GI6XQQ";
passwordlist[5] = "7LS6DVQ";
passwordlist[6] = "KIV8FKL";

displaypass = passwordlist[ans];

//Display a window with the variable "disp"
 disp = window.open("","pop","height=" + poph + ",width=" + 
        popw + ",left=" + 
        myWinWidth + ",top=" + myWinHeight + "");

//Write The content of the page
 content = '<HTML>';
 content += '<TITLE>Pop-up Window</TITLE>';
 content += '<BODY BGCOLOR="#FFFFFF" onBlur="self.close()">';
 content += '<H3 ALIGN="CENTER">' + displaypass + '</H3>';
 content += '</BODY></HTML>';
 disp.document.write(content);
 disp.document.close();
}
</Script>

Instead of submiting a form.
Create a link beside the input box with

Code:
<FORM name="in" other atributes here>
<Input type="text" name="code">
<A href="#" onclick="getNum(); return false;" Title="Get Code">Get code</A>
</Form>

I didnt test this all but the concept is there. Hope this helps, rep or np appreciated if helpfull.
 
0
•••
I'm sure that I'm just missing something but the script is not working I've played around with it for a few hours now.

I think I just need to catch some zzz and try it again later.

I sent you some np$

Thanks,

Steve

tgo said:
JS can do this

Method 1:
Use a cookie

Method 2:
Use the querystring

Method 3:
Use a popup.

I would go with method 3

Here is the js that should do this.
Code:
<Script>
//get the number from the form field and call main function with it
function getNum() {
  var num;
  num = document.form.in.code.value;
  answer(num);
}
//Function to popup a window and write the value of the variable.
function answer(ans)
{
 poph = 100;
 popw = 100;
 var displaypass;
 var myWinWidth = (window.screen.width/2) - (popw/2);
 var myWinHeight = (window.screen.height/2) - ((poph/2) + 50);

passwordlist = new Array(1001);
passwordlist[1] = "49TIIJT";
passwordlist[2] = "JLPBE35";
passwordlist[3] = "JW3O988";
passwordlist[4] = "9GI6XQQ";
passwordlist[5] = "7LS6DVQ";
passwordlist[6] = "KIV8FKL";

displaypass = passwordlist[ans];

//Display a window with the variable "disp"
 disp = window.open("","pop","height=" + poph + ",width=" + 
        popw + ",left=" + 
        myWinWidth + ",top=" + myWinHeight + "");

//Write The content of the page
 content = '<HTML>';
 content += '<TITLE>Pop-up Window</TITLE>';
 content += '<BODY BGCOLOR="#FFFFFF" onBlur="self.close()">';
 content += '<H3 ALIGN="CENTER">' + displaypass + '</H3>';
 content += '</BODY></HTML>';
 disp.document.write(content);
 disp.document.close();
}
</Script>

Instead of submiting a form.
Create a link beside the input box with

Code:
<FORM name="in" other atributes here>
<Input type="text" name="code">
<A href="#" onclick="getNum(); return false;" Title="Get Code">Get code</A>
</Form>

I didnt test this all but the concept is there. Hope this helps, rep or np appreciated if helpfull.
 
0
•••
Thx for the np,

Please post any errors you have, as stated I did not test this in a browser. I just went off experiance.

I will atempt to test this code tomorow and make sure it works if someone has not helped you by then. I am sure it will work, but the syntax may be off a bit as I have been coding asp lately.

I will check in again tomorow and test this. :)
 
0
•••
As is I get the following error:
Line: 5
CHAR: 23
ERROR: Expected identifier
CODE:0

and no popup.

I did play around with it a little and was able to get the popup but then I got the error "undefined" in the popup box.

Thanks,

Steve

tgo said:
Thx for the np,

Please post any errors you have, as stated I did not test this in a browser. I just went off experiance.

I will atempt to test this code tomorow and make sure it works if someone has not helped you by then. I am sure it will work, but the syntax may be off a bit as I have been coding asp lately.

I will check in again tomorow and test this. :)
 
0
•••
Tested this now
- changed the name of the form and added attributes.
- changed to document.forms.choice.c.value;
- working example http://famousqt.com/test/test.html

This goes in the head
Code:
<Script>
//get the number from the form field and call main function with it
function getNum() {
  var num;
  num = document.forms.choice.c.value;
  answer(num);
}
//Function to popup a window and write the value of the variable.
function answer(ans)
{
 poph = 200;
 popw = 200;
 var displaypass;
 var myWinWidth = (window.screen.width/2) - (popw/2);
 var myWinHeight = (window.screen.height/2) - ((poph/2) + 50);

passwordlist = new Array(1001);
passwordlist[1] = "49TIIJT";
passwordlist[2] = "JLPBE35";
passwordlist[3] = "JW3O988";
passwordlist[4] = "9GI6XQQ";
passwordlist[5] = "7LS6DVQ";
passwordlist[6] = "KIV8FKL";

displaypass = passwordlist[ans];

//Display a window with the variable "disp"
 disp = window.open("","pop","height=" + poph + ",width=" + 
        popw + ",left=" + 
        myWinWidth + ",top=" + myWinHeight + "");

//Write The content of the page
 content = '<HTML>';
 content += '<TITLE>Pop-up Window</TITLE>';
 content += '<BODY BGCOLOR="#FFFFFF" onBlur="self.close()">';
 content += '<H3 ALIGN="CENTER">' + displaypass + '</H3>';
 content += '</BODY></HTML>';
 disp.document.write(content);
 disp.document.close();
}
</Script>

This goes in the body
Code:
<CENTER>
<form method="post" action="#" name="choice">
<Input type="text" name="c">
<A href="#" onclick="getNum(); return false;" Title="Get Code">Get code</A>
</Form>
</CENTER>

Hope this gets you going.
 
Last edited:
0
•••
Thanks looks like that did the job. :tu:

Steve


tgo said:
Tested this now
- changed the name of the form and added attributes.
- changed to document.forms.choice.c.value;
- working example http://famousqt.com/test/test.html

This goes in the head
Code:
<Script>
//get the number from the form field and call main function with it
function getNum() {
  var num;
  num = document.forms.choice.c.value;
  answer(num);
}
//Function to popup a window and write the value of the variable.
function answer(ans)
{
 poph = 200;
 popw = 200;
 var displaypass;
 var myWinWidth = (window.screen.width/2) - (popw/2);
 var myWinHeight = (window.screen.height/2) - ((poph/2) + 50);

passwordlist = new Array(1001);
passwordlist[1] = "49TIIJT";
passwordlist[2] = "JLPBE35";
passwordlist[3] = "JW3O988";
passwordlist[4] = "9GI6XQQ";
passwordlist[5] = "7LS6DVQ";
passwordlist[6] = "KIV8FKL";

displaypass = passwordlist[ans];

//Display a window with the variable "disp"
 disp = window.open("","pop","height=" + poph + ",width=" + 
        popw + ",left=" + 
        myWinWidth + ",top=" + myWinHeight + "");

//Write The content of the page
 content = '<HTML>';
 content += '<TITLE>Pop-up Window</TITLE>';
 content += '<BODY BGCOLOR="#FFFFFF" onBlur="self.close()">';
 content += '<H3 ALIGN="CENTER">' + displaypass + '</H3>';
 content += '</BODY></HTML>';
 disp.document.write(content);
 disp.document.close();
}
</Script>

This goes in the body
Code:
<CENTER>
<form method="post" action="#" name="choice">
<Input type="text" name="c">
<A href="#" onclick="getNum(); return false;" Title="Get Code">Get code</A>
</Form>
</CENTER>

Hope this gets you going.
 
0
•••

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Live Options
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back