Webmaster Forum

Bidding Directory   Improve your ranking, submit to directories   V7N Directory
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Reply
 
LinkBack Thread Tools Display Modes
Old 04-09-2008, 08:43 PM   #1 (permalink)
Junior Member
 
Join Date: 04-04-08
Posts: 4
iTrader: 0 / 0%
Latest Blog:
None

derky is liked by many
java script if replace statement

hey!! right now i am a little confused about my if statement...i am not sure if i am writing it wrong because the code works completely fine until i add the if statement to it......well what i want to do is this i have one input box....and i have a output box....i would like to set it up to where if the user inputs a value that is not equal to blank space but xxx in the output box....but if the user inputs nothing at all in the input box put xxx in the output box....the output really doesnt matter i am just trying to get anything to go in the box....all of this code is in one function....and this function is called after the user pressed the submit button anyhoo...here is my code i hope you can help!!

function createCode()
{var userAboutMe = document.div01.about.value;
var userFriend = document.div01.friend.value;
var aboutCode = "" ;
var meetCode = divCode.replace(/XXXXXX/g, userFriend);
document.div01.meetcode.value = meetCode;
if (userAboutMe == aboutcode)
{
document.div01.aboutcode.value = yes;
}
else
document.div01.aboutcode.value = no;
}



}
</script>



<form name="div01">
<b>Step 1</b>
<br>
Please enter the information you would like in your about section:
<br><br>
<textarea name="about" rows="10" cols="40"></textarea><br><br>

<b>Step 3</b><br>
Please click "create code" to get your lyt code or "start over" to erase.
<br><br>
<input type="button" value="Create Code" onclick="createCode();">
<input type="reset" value="Start Over">
<br><br>
<b>Step 4</b><br>
Go to edit your profile, and erase everything that is in your profile sections
<br><br>
<b>Step 5</b><br>
Put the following code in your about me section
<br>
<textarea name="aboutcode" rows="10" cols="30"></textarea>
</form>
derky is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 04-11-2008, 09:53 AM   #2 (permalink)
v7n Mentor
 
Taltos's Avatar
 
Join Date: 11-22-06
Location: Phoenix, AZ
Posts: 1,787
iTrader: 0 / 0%
Latest Blog:
None

Taltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web pro
Send a message via Yahoo to Taltos
Your if statement doesn't look to be the problem.

My quick guess would be this line:
Code:
var meetCode = divCode.replace(/XXXXXX/g, userFriend);
You haven't defined "divCode" anywhere as a string but you are using the replace method on it. Javascript has a nasty habit of just stopping and not running any further lines when it hits an error. I suspect your if statement is never being run as you are getting an error on the line above.

Are you getting any errors? Are you seeing the "Done with errors" warning yellow triangle down in the bottom corner of the browser? Try commenting out that one line and see what happens.

Good Luck!

P.S. In the future, stick your code inside code tags. If you don't know what they are then just use the square brackets [ ] around the word "code" to open and around "/code" to close.
__________________
Experimenting
Taltos is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-11-2008, 12:27 PM   #3 (permalink)
Junior Member
 
Join Date: 04-04-08
Posts: 4
iTrader: 0 / 0%
Latest Blog:
None

derky is liked by many
yes i did have the var div code in the script....i just did not post it to the forum....should i post my full code to get help
derky is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-11-2008, 12:33 PM   #4 (permalink)
v7n Mentor
 
Taltos's Avatar
 
Join Date: 11-22-06
Location: Phoenix, AZ
Posts: 1,787
iTrader: 0 / 0%
Latest Blog:
None

Taltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web pro
Send a message via Yahoo to Taltos
It can help to post it all if it is not HUGE. If it is huge, have you stuck alerts in just to see if the JS is even getting to your if statement? Maybe post all the JS at least?
__________________
Experimenting
Taltos is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-11-2008, 12:54 PM   #5 (permalink)
Junior Member
 
Join Date: 04-04-08
Posts: 4
iTrader: 0 / 0%
Latest Blog:
None

derky is liked by many
here is the full code...i hope this helps.....and i havent put any alerts

Code:
<SCRIPT LANGUAGE="JavaScript"> var aboutMe = "<div class=\"aboutme\">&nbsp;</div>"; var divCode = "<div class=\"bg\"><img src=\"http://www.freewebs.com/derkyd/div/div01.png\" width=\"800\" height=\"600\" border=\"0\" usemap=\"#map\"><map name=\"map\"><area shape=\"rect\" coords=\"515,376,621,438\" href=\"http://viewmorepics.myspace.com/index.cfm?fuseaction=user.viewAlbums&friendID=XXXXXX\"><area shape=\"rect\" coords=\"470,440,588,508\" href=\"http://mail.myspace.com/index.cfm?fuseaction=mail.message&friendID=XXXXXX\"><area shape=\"rect\" coords=\"441,505,561,581\" href=\"http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=XXXXXX\"><area shape=\"rect\" coords=\"739,580,798,601\" href=\"http://www.skem9.com/~180831\"></map></div><div class=\"cmtbox\"><form method=\"post\" action=\"http://comments.myspace.com/index.cfm?fuseaction=user.ConfirmComment\"><input name=\"friendID\" value=\"XXXXXX\" type=\"hidden\"><textarea name=\"f_comments\" class=\"pnckdbox\">comment me</textarea><bR><input type=\"submit\" value=\"Send Comment\" class=\"pnckdcom\"></form><style type=\"text/css\">textarea.pnckdbox {background-color:transparent !important;width:100px !important; height:65px !important;color:ffffff !important;font-size:12px !important;overflow:hidden;border-color:9E136C !important;border-style:solid !important;border-width:2px !important;} input.pnckdcom {color:ffffff !important;font-size:10px !important;width:100px !important;height:20px !important;letter-spacing:1px !important;text-transform:uppercase !important;border-color:9E136C !important;border-style:solid !important;border-width:2px !important;}</style> </center> </div><style>.cmtbox { background-color: transparent;position: absolute;left: 50%; margin-left: -20px; top: 500px; overflow: none; z-index: 2;}.bg { background-color: transparent;position: absolute; left: 50%; margin-left: -400px; top: 210px; width: 800px; overflow: none; z-index: 1;} .aboutme { background-color: transparent; position: absolute; left: 50%; margin-left: -350px; top: 280px; width: 300px; height: 470px; overflow: auto; z-index: 2;} .comt td, .comt table{width:0px!important; height:0px!important; background-color:transparent!important; border:0px!important; _padding:2px!important;} .comt, .comt td, .comt table, .comt td a img, .comt td td td a, .comt td b a, .comt td .redlink{visibility:visible;} .comt td td td b{top:0px; display:inline;} .comt td td td table, .comt .orangetext15, .redlink, .comt .btext, .frnd{display:none;} .comt td b, .blacktext10 {display:block;} .comt {z-index:7;}.comt table, .comt b {position:relative; top:-39px; _top:-30px;}.comt {width:400px; height:140px; overflow:auto;background-color:transparent; position:absolute; top:280px; left:50%; margin-left:-20px; }.comt {scrollbar-face-color: 9E136C; scrollbar-highlight-color: 9E136C; scrollbar-3dlight-color: 9E136C; scrollbar-shadow-color: 9E136C; scrollbar-darkshadow-color: 9E136C; scrollbar-arrow-color: 000000; scrollbar-track-color: 9E136C;}</style> <style> table, tr, td {background-color:transparent; border:0px;} table table table {background-color: transparent;} table table table tr td {background-color:transparent;} body{background-color:000000; scrollbar-face-color:000000; scrollbar-highlight-color:000000; scrollbar-3dlight-color:000000; scrollbar-shadow-color:000000; scrollbar-darkshadow-color:000000; scrollbar-arrow-color:9E136C; scrollbar-track-color:000000;}textarea, button, input, select { font-family:tahoma; font-size:10px; line-height:9px; color:ffffff; font-weight:normal; text-decoration:none; text-transform:none; border-width:2px; border-style: solid; border-color: 9E136C; background-color:000000;} b, strong {color : 000000;} u {color :000000; font-style : normal; font-weight : normal; border-bottom : 1px dotted 000000;} i {font-family : georgia; text-transform : none; text-decoration : none; color: 000000;} s{color : 000000;} a:active {color:000000; font-family: century gothic; font-size:10;} a:visited {color:000000; font-family: century gothic; font-size:10;} a:link {color:000000; font-family: century gothic; font-size:10;} a:hover {color:ffffff; font-family: century gothic; font-size:10;} a.navbar:active {color:9E136C; font-family: century gothic; font-size:10;} a.navbar:visited {color:9E136C; font-family: century gothic; font-size:10;} a.navbar:link {color:9E136C; font-family: century gothic; font-size:10;} a.navbar:hover {color:ffffff; font-family: century gothic; font-size:10;} .blacktext10 {color:9E136C; border-color:ffffff; border-bottom-width:0px; border-style:solid; font-family: century gothic; font-size:12; text-align: center; display:block; border-top-width:3px; border-right-width:0px; border- left-width:0px;background-color:000000;} .orangetext15 {color:9E136C; border-color:ffffff; border-bottom-width:0px; border-style:solid; font-family: century gothic; font-size:12; text-align: center; display:block; border-top-width:3px; border-right-width:0px; border-left-width:0px;background-color:000000;} .redtext {color:9E136C; font-family: century gothic; font-size:12;} table, tr, td, p, div, li, ul, .text {color:ffffff; font-family: century gothic; font- size:10;}</style><style>.profileInfo {display:none;} .contactTable {display:none;} .UserProfileURL {display:none;} .UserProfileDetail {display:none;} .UserProfileSchool {display:none;} .UserProfileNetwork {display:none;} .UserProfileCompany {display:none;}</style><style>td.text div object, td.text div embed {display:none;} td.text td div object, td.text td div embed {display:block;} .extendedNetwork, .latestBlogEntry {display:none;} td.text br {display:none;} .profileInfo td.text br, td.text table br {display:inline;} .friendsComments td table, .friendsComments td.text table, .friendSpace table, .blurbs, .blurbs td.text {background-color:transparent; border:0px;}tr {background-color:transparent;} table div {display:none;} div table div, table table div {display:block;}td {height:0px;}</style> <style>strong {display:none;} .contactTable td.text {display:none;} .contactTable td td.text {display:table-cell; _display:inline;} .interestsAndDetails td.text {display:none;} .userProfileDetail td.text {display:none;} td.text td.text .whitetext12 {display:none;} .interestsAndDetails .lightbluetext8 {display:none;} .interestsAndDetails td {width:0px;} .userProfileDetail .lightbluetext8 {display:none;} .userProfileDetail td {width:0px;} .latestBlogEntry .btext {display:none;} .friendSpace table, .blurbs, .blurbs td.text {background-color: transparent;} .blurbs .orangetext15 {display:none;} </style><style> embed, object {filter:alpha(opacity=0.1); opacity:0.01; -khtml-opacity:0.01;} .a {unhide other embeds including video slider} td td td td embed, td td td object, td.text embed, td.text object {filter:none; opacity:none; -khtml-opacity:none;} .interestsAndDetails {margin-top:-90px;} </style>DerkyCredit <style>embed, object {width:0px; height:0px;} table table table embed, table table table object {width:320px; height:240px;} </style></td></tr></table></td></tr></table> <div class=\"comt\"><table class=\"off\"><tr><td><table><tr><td>"; function createCode() {var userAboutMe = document.div01.about.value; var userFriend = document.div01.friend.value; var aboutCode = "" ; var meetCode = divCode.replace(/XXXXXX/g, userFriend); document.div01.meetcode.value = meetCode; if (userAboutMe == aboutcode) { document.div01.aboutcode.value = yes; } else document.div01.aboutcode.value = no; } } </script> </HEAD> <BODY> <div class="content"> <h1>Div 01 - Emo - Emo Chick</h1> <center> <form name="div01"> <b>This is the div layout generator. All you have to do is fill in all the information that is required. No longer will you have to mess with sticky confusing codes, or changing the infamous friend id. With this simple step generator you can have a unique layout without the headache or confusion. So what are you waiting on get started!!</b> <br><br> </center> <b>Step 1</b> <br> Please enter the information you would like in your about me section: (you can put anything in here. text, pictures, vidoes, music player etc.)</center> <br><br> <textarea name="about" rows="10" cols="40"></textarea><br><br> <b>Step 2</b><br> Please enter your friend id<br><br> <input type="text" value="" name="friend" rows="10" cols="30"></textarea><br><br> If you do not know what your friend id is : <ol> <li>Go to myspace.com</li> <li>Log into your account</li> <li>Click view my profile to look at your page</li> <li>Look at the top address bar. </li> </ol> You should see something like this:<br> <img src="http://i221.photobucket.com/albums/dd106/derkylyt/category/friendid.png"> <br> Your friend id is the last numbers in the address bar (the boxed in part above is the friend id of a profile). <br><br> <b>Step 3</b><br> Please click "create code" to get your lyt code or "start over" to erase. <br><br> <input type="button" value="Create Code" onclick="createCode();"> <input type="reset" value="Start Over"> <br><br> <b>Step 4</b><br> Go to edit your profile, and erase everything that is in your profile sections <br><br> <b>Step 5</b><br> Put the following code in your about me section <br> <textarea name="aboutcode" rows="10" cols="30"></textarea> <br><br> <b>Step 6</b><br> Put the following code in your who is like to meet <br> <textarea name="meetcode" rows="10" cols="30"></textarea> <br><br> <b>Step 7</b><br> Leave a rating on the layout. Tell me honestly what you think of it <br><br> <script type="text/javascript" src="http://images.freewebs.com/JS/fw.js"></script> <script type="text/javascript" src="http://images.freewebs.com/JS/fwRatingBox.js"></script> <script type="text/javascript" src="http://link.members.freewebs.com/Members/Feedback/loadRatingBoxJS.jsp?ownerID=26884847&listID=7804787&limit=5&duration=40&showRatings=true&showComments=false&startHidden=false"></script> </form>
derky is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
images off? Java Script off? Flash off? Kymberly Web Usability 18 10-26-2007 12:42 AM
preg replace - replace links pairbrother Coding Forum 4 06-19-2007 12:19 PM
need help w/ find and replace script... PhoenixSlayerSX Coding Forum 0 01-07-2007 11:48 AM
Java Script to run Java Script pippyboy Coding Forum 1 06-13-2004 11:31 AM
PLEASE Help with Java Script !!! CrAg Coding Forum 1 04-21-2004 02:22 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 05:11 AM.
© Copyright 2008 V7 Inc