Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-19-2012, 04:19 PM   PM User | #1
teedoff
Senior Coder

 
Join Date: Aug 2010
Location: High Point, NC
Posts: 3,325
Thanks: 5
Thanked 363 Times in 360 Posts
teedoff is on a distinguished road
syntax error

Hi been a long time since I've been here.

I have a bit of js that adds a couple of html elements based on the value of a loop. I have a syntax error and cant spot what I've done wrong.

The error says I'm missing a closing ), but they seems to be all matched. I suspect its my quotes and double quotes, but not sure I know whats wrong with what I have now.

My js:
Code:
  $(document).ready(function(){
   $("##addSMRow").bind("click", function(){
    if($(".sm_row").size() < 3){
     $("##addSMRow").prev().append('<div class="sm_row"><div class="select socialMediaSite"><select name="socialMediaSite">#variables.artistData.socialOptionsNew#</select></div><input type="text" name="socialMediaValue" id="socialMediaValue" value="" /> <a href="##" class="remove_row">#variables.metaData.dsp["removeTxt"]#</a></div>');
    }
    if($(".sm_row").size() == 3){
     $("##addSMRow").hide();
    }
    else{
     $("##addSMRow").show();
    }
    return false;
   });
   if($(".sm_row").size() == 3){
    $("##addSMRow").hide();
   }
   $(".remove_row").live("click", function(){
    $(this).parent().remove();
    $("##addSMRow").show();
    return false;
   });
  });
The line the error is not liking is the fourth line I believe. Thanks for any help with his.
__________________
Teed
teedoff is offline   Reply With Quote
Old 09-19-2012, 05:23 PM   PM User | #2
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 952
Thanks: 7
Thanked 98 Times in 98 Posts
WolfShade is an unknown quantity at this point
Glad to see another CF developer on the site!

What does the IE or FF error console say?
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Old 09-19-2012, 06:16 PM   PM User | #3
teedoff
Senior Coder

 
Join Date: Aug 2010
Location: High Point, NC
Posts: 3,325
Thanks: 5
Thanked 363 Times in 360 Posts
teedoff is on a distinguished road
Sorry forgot to include that. Yep CF here! Not many of us around..lol

Thanks for the assistance.

Timestamp: 9/19/2012 11:41:13 AM
Error: SyntaxError: unterminated string literal
Source File: https://dev.getconquer.com/index.cfm...dingArtistInfo
Line: 672, Column: 41
Source Code:
$("#addSMRow").prev().append().html("<div class='sm_row'><div class='select socialMediaSite'><select name='socialMediaSite'>
__________________
Teed
teedoff is offline   Reply With Quote
Old 09-19-2012, 06:33 PM   PM User | #4
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 454 Times in 452 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
it seems like you may want to try this:

Code:
$("##addSMRow").prev().append('<div class="sm_row"><div class="select socialMediaSite"><select name="socialMediaSite"><cfoutput>#variables.artistData.socialOptionsNew#</cfoutput></select></div><input type="text" name="socialMediaValue" id="socialMediaValue" value="" /> <a href="##" class="remove_row"><cfoutput>#variables.metaData.dsp["removeTxt"]#</cfoutput></a></div>');
xelawho is offline   Reply With Quote
Old 09-19-2012, 06:37 PM   PM User | #5
teedoff
Senior Coder

 
Join Date: Aug 2010
Location: High Point, NC
Posts: 3,325
Thanks: 5
Thanked 363 Times in 360 Posts
teedoff is on a distinguished road
Quote:
Originally Posted by xelawho View Post
it seems like you may want to try this:

Code:
$("##addSMRow").prev().append('<div class="sm_row"><div class="select socialMediaSite"><select name="socialMediaSite"><cfoutput>#variables.artistData.socialOptionsNew#</cfoutput></select></div><input type="text" name="socialMediaValue" id="socialMediaValue" value="" /> <a href="##" class="remove_row"><cfoutput>#variables.metaData.dsp["removeTxt"]#</cfoutput></a></div>');
Thanks Xelawho. I'm restricted from using cfoutputs in this manner though. lol We have very strict coding guidelines here and one of our standards says cfoutputs wrap the entire view, so I have an opening one for the first line and a closing one for that last line of every html document we code.
__________________
Teed
teedoff is offline   Reply With Quote
Old 09-19-2012, 06:39 PM   PM User | #6
teedoff
Senior Coder

 
Join Date: Aug 2010
Location: High Point, NC
Posts: 3,325
Thanks: 5
Thanked 363 Times in 360 Posts
teedoff is on a distinguished road
Crap how stupid am I?? lol its breaking on the hash marks. Escaping them seems to have eliminated my code! Not sure the js works correctly or not, but thanks all!
__________________
Teed
teedoff is offline   Reply With Quote
Old 09-19-2012, 06:49 PM   PM User | #7
teedoff
Senior Coder

 
Join Date: Aug 2010
Location: High Point, NC
Posts: 3,325
Thanks: 5
Thanked 363 Times in 360 Posts
teedoff is on a distinguished road
Ok well the original issue is fixed, however now I have a new issue. When I click the text to add a row, it does indeed add a row. Upon adding a row, it should display a text link for removing a row. Instead this displays the literal value of the variable.....

So instead of displaying a text link "Remove Row",

it displays:
#variables.metaData.dsp["removeTxt"]#
__________________
Teed
teedoff is offline   Reply With Quote
Old 09-19-2012, 07:35 PM   PM User | #8
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 952
Thanks: 7
Thanked 98 Times in 98 Posts
WolfShade is an unknown quantity at this point
That just means that the code isn't wrapped with <cfoutput></cfoutput>.

Or am I missing something?
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Old 09-20-2012, 02:27 PM   PM User | #9
teedoff
Senior Coder

 
Join Date: Aug 2010
Location: High Point, NC
Posts: 3,325
Thanks: 5
Thanked 363 Times in 360 Posts
teedoff is on a distinguished road
Quote:
Originally Posted by WolfShade View Post
That just means that the code isn't wrapped with <cfoutput></cfoutput>.

Or am I missing something?
No the whole document is wrapped with cfoutputs. lol

Thanks for the help. It is now fixed and reworked so I dont have all that crap html inside an append function. If interested, here's the js:

Code:
  $(document).ready(function(){
   $(".addSMRow").bind("click", function(){
    var $socialForms = $(".socialForms");
    if($(".sm_row").size() < 3){
     $(".moreSocial").append($socialForms.html());
    }
    if($(".sm_row").size() > 1){
     $(".remove_row").show()
    }
    if($(".sm_row").size() == 3){
     $(".addSMRow").hide();
    }
    else{
     $(".addSMRow").show();
    }
    return false;
   });
   if($(".sm_row").size() == 3){
    $(".addSMRow").hide();
   }
   $(".remove_row").live("click", function(){
    $(this).parent().remove();
    $(".addSMRow").show();
    return false;
   });
  });
__________________
Teed
teedoff is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:55 AM.


Advertisement
Log in to turn off these ads.