Solved

Determine if tag contains certain parameter

Posted on 2013-05-23
5
167 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Align a <div> to a table row 3 39
get radio button vale in array 7 37
Safari SVG Image Problem 1 20
gif animation 6 19
There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
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…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now