[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Apparent collision of square brackets in jQuery and Classic ASP

Posted on 2012-04-10
12
Medium Priority
?
43 Views
Last Modified: 2016-04-24
Hello Everyone,

I am not an ASP guru and I am writing some code in Classic ASP and trying to introduce jQuery. Most things work well, however I have a problem with square brackets messing with what I presume to be the ASP parser. Typically functions are called in brackets like [ADD_PAGEHEADER] or [ADD_FORMSTART]. The problem seems to be the brackets in the jQuery script (below) are trying to be interpreted by the ASP parser, I think.

<script>
      $('input[name=FeatureList]').change(function() {
            $("#cb").append("this is a test");
      });  
</script>

The script fails at the point where the jQuery script begins in an ASP processed page, but works fine in straight HTML. In the script jQuery above, radio buttons seem to be handled a little differently than many other form elements and the syntax is a little quirky.

Is there anyway to turn off the ASP parser during the running of this script or maybe some other workaround to the apparent collision of the brackets? I tried escaping out the brackets but that didn't work either.

Thanks in advance for your help.

HB
0
Comment
Question by:HumbleBeginnings
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
12 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 2000 total points
ID: 37832034
I would expect

 $("input[name='FeatureList']")

http://api.jquery.com/attribute-equals-selector/
0
 
LVL 35

Expert Comment

by:YZlat
ID: 37832273
I think it should be

 $("#FeatureList").change(function() { 
            $("#cb").append("this is a test");
      });  

Open in new window

0
 
LVL 35

Expert Comment

by:YZlat
ID: 37832291
or something like:

 
$("input[type='checkbox'][name='FeatureList']").change(function() { 
            $("#cb").append("this is a test");
      });  

Open in new window


or

 
$("input:checkbox[name='FeatureList']").change(function() { 
            $("#cb").append("this is a test");
      });  

Open in new window

0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
LVL 35

Expert Comment

by:YZlat
ID: 37832304
Actually this should work fine:

 $('input[name="FeatureList"]').change(function() { 
            $("#cb").append("this is a test");
      });  

Open in new window

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37832445
Which is what I posted
0
 
LVL 35

Expert Comment

by:YZlat
ID: 37832641
to be fair, you posted

 $("input[name='FeatureList']")

and I posted

$('input[name="FeatureList"]')
0
 
LVL 35

Expert Comment

by:YZlat
ID: 37832645
and while yours modified the author's code, mine was simply wrapping FeatureList in double quotes
0
 
LVL 43

Expert Comment

by:David S.
ID: 37832681
Whether one type of quotes are used on the inside as opposed to the outside makes no functional difference. You just have to make sure that you escape any that need escaping (which is not needed in this example).

I think it should be
$("#FeatureList")
An ID and a name are not the same. An ID must be unique, where as, especially with radio button groups, multiple form controls may have the same name.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37832691
@YZlat: And this large amounts of unnecessary postings results in what? That we agree that the quotes are the issue?
I added the quotes to the selector - irrelevant which way the quotes are added as long as they are there. I modified them to my preference.
That does not make it less correct than a suggestion where I left the original quotes in place.

I agree with Kravimir - $("#...") is for ID and not for NAME. I did not want to pollute the question with even more posts so I did not mention it
0
 
LVL 35

Expert Comment

by:YZlat
ID: 37832981
mplungjan, talking about polluting the post...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question