Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Problem with javascript

Posted on 2012-08-29
7
Medium Priority
?
604 Views
Last Modified: 2012-08-29
I have the following script

function ChangeType(mType) {
                  if (mType == 1) {
                        $("#Section1").show();
                        $("#Section2").hide();
                        $("hfVType").val("Section1");
                        
                  }
                  else {
                        $("#Section1").hide();
                        $("#Section2").show();
                        $("hfVType").val("Section2");
                        
                  }
            };
the hide and show statements work fine, but I can not get the value of the hidden field to change.  I dont get any errors but when I use the value of the hidden field in vbscript upon hitting submit the value doesnt change.

thanks
0
Comment
Question by:mgmhicks
  • 2
  • 2
  • 2
  • +1
7 Comments
 

Author Comment

by:mgmhicks
ID: 38347445
I did also try

function ChangeType(mType) {
                  if (mType == 1) {
                        $("#Section1").show();
                        $("#Section2").hide();
                        $("#hfVType").val("Section1");
                        
                  }
                  else {
                        $("#Section1").hide();
                        $("#Section2").show();
                        $("#hfVType").val("Section2");
                        
                  }
            };


I am using a master page, not sure if that helps or not.
0
 
LVL 10

Expert Comment

by:Gregg
ID: 38347547
Can you post your html? I dont see a problem. Have a look at: http://jsfiddle.net/qnc5u/
0
 
LVL 20

Expert Comment

by:informaniac
ID: 38347555
hfVType would be the id that is  generated in the HTML.

If you do a viewsource you would be able to see the actual id for the hidden field that is generated.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 10

Expert Comment

by:Gregg
ID: 38347562
disregard my comment. I looking at wrong thing. oops.
0
 
LVL 20

Accepted Solution

by:
informaniac earned 2000 total points
ID: 38347564
$("#<%= hfVType .ClientID %>").val("Section2");
0
 
LVL 61

Expert Comment

by:HainKurt
ID: 38347579
post html code hfVType or give a link to the test page...
0
 

Author Comment

by:mgmhicks
ID: 38347733
here is what is it rendered

<input type="hidden" name="ctl00$ContentPlaceHolder1$hfVType" id="ctl00_ContentPlaceHolder1_hfVType" value="Section1" />

but I thought $("#hfVType) would be able to find that.  I use that for other controls.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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)
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

581 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