Aligning javascript code with other images

I’m using this short javascript snippet as a page password. I know it’s not a great protector, but it’ll be fine for the purpose.

My problem is trying to align it with other inline images. Regardless of the CSS I write (and I’m not real good at that, either), the js snippet forces the other images above it.

If it’s any help, the code contains a one-line input form (I tried posting the entire script, but it doesn’t show).

var suffix = ".htm"

var pass_msg ="<img src='imgs-nav/memb-login-icon.png' width='46' height='40'> &nbsp;&nbsp;";

function go_there() {
 location.href = document.pass_form.pass.value + suffix;

document.write('<form name="pass_form" onSubmit="go_there();return false">'
 + pass_msg + '<input class="memb-login" type="password" name="pass" size="20" value="">'
 + '&nbsp;&nbsp;<input type="image" "img src="imgs-nav/rt-arrow.png" align="absmiddle" width="30" height="30" alt="enter" border="0"><\/form>');

Is this typical of javascript, and if so, how can I correct to keep all the icons inline with the javascript form box?

This post has been reformatted by enclosing the code block in 3 backticks
on their own lines.

Can’t really tell without knowing what the other images are. Is this the full script?

HTML is how things are laid out and CSS is how a page looks, JS doesn’t really have any effect on that directly… so whatever your answer is, the correct answer is going to be with HTML/CSS.

Yes, basically we need to see an HTML/CSS demo (try CodePen) to see how the page is actually laid out. Whether the code is injected via JS or not doesn’t really matter.

Thanks,guys, I tried to do some absolute positioning, but had limited results. In going to tweak it some more, and if all else fails, I’ll let yo guys (and gals) look it over for me, Nothing more frustrating to get to the end of your coding, only to find it doesn’t display properly!

No, it’s not the full script above. For whatever reason, the text editor only oik a portion of it, This isn;t the exact sriot I;m using, but is close:

function passWord() {
var testV = 1;
var pass1 = prompt('Please Enter Your Password',' ');
while (testV < 3) {
if (!pass1) 
if (pass1.toLowerCase() == "letmein") {
alert('You Got it Right!');'protectpage.html');
var pass1 = 
prompt('Access Denied - Password Incorrect, Please Try Again.','Password');
if (pass1.toLowerCase()!="password" & testV ==3) 
return " ";
<input type="button" value="Enter Protected Area" onClick="passWord()">

Sorry, but I’m doing something wrong when trying to insert the code, Thanks again…

This post has been reformatted by enclosing the code block in 3 backticks
on their own lines.

Thank you! As long as I now know where to work, I’ll fiddle with the CSS layout until it all aligns. I DO appreciate your help!

This code is entirely different…


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.