Need help with JavaScript function

         $(function () {
              $("#date2").datepicker({
                  numberOfMonths: 2,
                  showButtonPanel: true
              });
          });

I have above function in the MasterPage.
All my Content pages use the MasterPage.

I need to change above function to pass id of the INPUT box (in this case it is hard-coded as #date2) from Content page.
I think I need to give the name for this function (maybe) and call from Content page (not sure).

I need to execute above function from Content page so that it can assign value to the INPUT box.

How do I code this?

Thanks,
Ashok
LVL 13
AshokSr. Software EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RickCommented:
The best way is to keep the Javascript code in a separate file.

Take a look at this link.
0
AshokSr. Software EngineerAuthor Commented:
That article is posted on February 2004.

I am using VS 2010 so it complains that the above is OBSOLETE.

Thanks,
Ashok
0
dejaanbuCommented:
in all of your content pages, put a specific class for the input boxes that you want to be a datepicker

that is something like this

<input id='mycontrol' class='datePick' type='text'/>

and in master page, you could have

$(function () {
              $(".datePick").datepicker({
                  numberOfMonths: 2,
                  showButtonPanel: true
              });
          });

so that it will make all inputboxes which have 'datePick' as the class  , as a datepicker

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

RickCommented:
Ashok,

It still works (even though it says it is obsolete).
But if you want to use the new way of registering a startup script, just change to this:

Page.ClientScript.RegisterStartupScript(type As System.Type, Key As String, script as String)


For example:

Page.ClientScript.RegisterStartupScript(GetType(Page), "MyScript", "<script>MyFunction();</script>")
0
AshokSr. Software EngineerAuthor Commented:
in my aspx page (content page), I have

                    <p>
                        <span class="copy">Returning:</span><br />
                        <input id="date2" class='datePick' type="text" name="firstinput7" size="20" />
                    </p>

and

$(function () {
              $(".datePick").datepicker({
                  numberOfMonths: 2,
                  showButtonPanel: true
              });
          });

but when I click on date2 input box, the calendar does not show up.

Thanks,
Ashok
0
AshokSr. Software EngineerAuthor Commented:
in my aspx page (content page), I have

                    <p>
                        <span class="copy">Returning:</span><br />
                        <input id="date2" class='datePick' type="text" name="date2" size="20" />
                    </p>

and

$(function () {
              $(".datePick").datepicker({
                  numberOfMonths: 2,
                  showButtonPanel: true
              });
          });

but when I click on date2 input box, the calendar does not show up.

Thanks,
Ashok
0
AshokSr. Software EngineerAuthor Commented:
No answer to my question.
Please close this question.

I have opened another question similar to this for the same problem.

Ashok
0
AshokSr. Software EngineerAuthor Commented:
I've requested that this question be deleted for the following reason:

No answer to my question.<br />Please close this question.<br /><br />I have opened another question similar to this for the same problem.<br /><br />Ashok
0
dejaanbuCommented:
though u have closed  ur question quickly, i am giving a little suggestion to it.

did u check Firefox ErrorConsole for any js errors ?
0
AshokSr. Software EngineerAuthor Commented:
dejaanbu,

I should have checked.  How do I bring it up.  I have never used it.
Do I have to install anything on top of default FireFox?

In any case, my problem is solved with another question at
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_27510803.html

Should I just place one jQuery in MasterPage and use only one version of the jQuery?
YES (is the answer).

Thanks,
Ashok
0
dejaanbuCommented:
your pbm is already solved. though,

In default firefox (if u have current version), you can see it in Firefox -> Web Developer ->Error Console


further,


i will give u a short description about Firebug.

it is a firefox addon that integrates with Firefox to put a wealth of development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.

from, here you can install it,

https://addons.mozilla.org/en-US/firefox/addon/firebug/
0
AshokSr. Software EngineerAuthor Commented:
Need to give points to dejaanbu (last comment after Close request).
0
AshokSr. Software EngineerAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.