Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9

Thread: syntax error

  1. #1
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,338
    Thanks
    5
    Thanked 363 Times in 360 Posts

    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

  • #2
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    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".

  • #3
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,338
    Thanks
    5
    Thanked 363 Times in 360 Posts
    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

  • #4
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,980
    Thanks
    56
    Thanked 557 Times in 554 Posts
    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>');

  • #5
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,338
    Thanks
    5
    Thanked 363 Times in 360 Posts
    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

  • #6
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,338
    Thanks
    5
    Thanked 363 Times in 360 Posts
    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

  • #7
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,338
    Thanks
    5
    Thanked 363 Times in 360 Posts
    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

  • #8
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    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".

  • #9
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,338
    Thanks
    5
    Thanked 363 Times in 360 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •