Solved

Determine if tag contains certain parameter

Posted on 2013-05-23
5
176 Views
Last Modified: 2013-05-23
<form method="post" action="Asset.aspx?MenuId=409&amp;AssetTaskID=2841409-1&amp;AssetID=34878-1&amp;IsPopup=true"

vs

 <form method="post" action="Asset.aspx?MenuId=396&amp;AssetID=34878-1" id="frmMain" enctype="multipart/form-data">


I want to know if the <form /> tag contains the   "IsPopup" parameter and do something if it does / does not.
0
Comment
Question by:knowlton
  • 3
  • 2
5 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 39191203
Add id attribute to the form and use this jquery:
if($("#myForm").attr('action').val().insexOf('IsPopup')>-1){

}
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 39191206
indexOf not insexOf.
0
 
LVL 5

Author Comment

by:knowlton
ID: 39191226
Okay.

Now, what if I do not want to add attribute "id".   Can it still work?

I do not want to disturb the way the form tag is currently rendered.
0
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 39191265
Its not gonna affect the form at all.
U can also use class instead of id and then replace the # character with . (dot)
0
 
LVL 5

Author Closing Comment

by:knowlton
ID: 39191312
My final solution:

if ($("form#frmMain").attr('action').indexOf('IsPopup') < 0) {  

            $('input').attr('disabled', true);
            $('select').attr('disabled', true);
            $('div[id*="divSave"]').css('display', 'none');
            $('span[id*="spnCalculateTotals"]').css('display', 'none');
        }

Open in new window


Thank you for your help!!  :  )
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
The viewer will learn how to dynamically set the form action using jQuery.
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)

809 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