vForums Support > Programming & Coding :: Code Requests & Support :: > [ASAP Please :P] Code Fix

[ASAP Please :P] Code Fix - Posted By dog199200 (dog199200) on 2nd Nov 08 at 7:18am
Can someone please help me fix this code, for some reason the get variables ain't working after I switched the code's design to an array.

Code:
 
  1. <script type="text/javascript">
  2. <!--
  3. /*
  4. Guest Friendly Message by Dwight
  5. Copyright© 2008 Infinity Codes
  6. http://icodes.vforums.co.uk
  7. Do not Repost
  8. */
  9.  
  10. //Edit Below
  11.  
  12. var wtp = 2; //0 = above banner, 1 = above menu buttons, 2 = below menu buttons
  13.  
  14. var message = ['We hope you enjoy your visit.<br /><br /><br />You re currently viewing the our forum as a guest. This mean you are limited to certain areas of the board and there are some features you can not use. If you join our community, you ll be able to access the member-only sections, and use many member-only features such as customizing your profile, sending private messages, and voting in polls. Registration is simple, fast, and completely free.<br /><br /><br /><font color="#FF6600">Join our community! <a href=/action/register>Register Now!</a></font><br /><br /><br />If you are already a member please login to your account to access all the features:']; // Do not use 's, they will cause the code to break.
  15.  
  16. var form = ['<form action=javascript:void;(0); onsubmit=login();>Username: <input type="text" id="un" size="20"> Password: <input type="password" id="pw" size="20"> <input type="submit" value="Login"></form>'];
  17.  
  18. //Edit Above
  19.  
  20. function build(){
  21. var wt = document.getElementByI00;("welcome_table");
  22. var nRow=wt.insertRow(wtp);
  23. var nCell=nRow.insertCell(0);
  24. nCell.className="window1";
  25. nCell.innerHTML = message + "<br />" + form;
  26. }
  27. function login(){
  28.     get('username','name')[0].value = get('un','id').value;<span><wbr /></span>
  29.     get('password','name')[0].value = get('pw','id').value;<span><wbr /></span>
  30.     get('loginForm','name').submit();
  31. }
  32. if(location.href.match(/.co.uk($|\/$)/) && vf_username == 'guest'){
  33.     build();
  34. }
  35. //-->
  36. </script>
 

Re: [ASAP Please :P] Code Fix - Posted By Marc (cr0w) on 7th Nov 08 at 8:07pm
I see numerous <span><wbr /></span> tags in the code you posted. Were those placed into the code by you, or is that something that happened when you posted the code here?

Re: [ASAP Please :P] Code Fix - Posted By dog199200 (dog199200) on 9th Nov 08 at 4:10am
I didnt add them in

Edit: but I went ahead and removed them

Re: [ASAP Please :P] Code Fix - Posted By Marc (cr0w) on 9th Nov 08 at 6:17pm
Since you're using an array, to add the message and form anywhere, you need to tell it which index in the array to grab. You would need to use message[0] and form[0] to access it.

However, I see no reason for you to be using arrays; they are completely useless in this situation and only add to the amount of time & processing power needed for the code to run. {Unsure}

Re: [ASAP Please :P] Code Fix - Posted By dog199200 (dog199200) on 10th Nov 08 at 12:28am
i was using arrays to make the code easier to edit instead of one big code area to edit, by using an array I have it so the information is split up and easier to edit, at least in my own opinion.

And ok i'll add those in when i get home and see what happeneds

Re: [ASAP Please :P] Code Fix - Posted By dog199200 (dog199200) on 10th Nov 08 at 3:31am
Edit: OK Ross Pm'd me what was wrong, I forgot to add a [0] to the submit function.