Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Confirm Method

Status
Not open for further replies.

greyone

Programmer
Dec 14, 2000
200
CA
Hi
I have this wiered problem with the confirm method

i have a function with the same name as confirm but it takes 3 parameters as shown below. Now when i want to use the built in confirm method of jaascript it seems to be getting overloaded with the my own confirm function> Is there a way i can prven this from happening. Please help

Her is the code:

<script language=&quot;javascript&quot;>
function f2()
{
var test = confirm (&quot;Delete?&quot;)
}

function confirm(str1,str2,str3)
{
alert(&quot;my confirm&quot;)
}
</script>
<body>
<input type=&quot;button&quot; value=&quot;click here&quot; onClick=&quot;javascript: f2()&quot;>
</body>

 
Confirms in JavaScript work like this.

Code:
if (window.confirm(&quot;Delete ?&quot;)) {
  // Do something if yes is selected
} else {
  // Do something if canceled is selected
}

Is that what you were looking for ??

ToddWW
 
noop man i have another function which has the same name as the built in method confirm.
And it seems to be always calling my confirm method insted of the built in method.
 
Oh I see. Why don't you rename your function ??

ToddWW
 
this is because you used the reserved word, confirm as your function call. try changing it to myConfirm(). theEclipse
eclipse_web@hotmail.com
Icq: 124408594
online.dll

AIM & MSN: robacarp
 
is there a workaround to this since i have this function on almost all pages. Chaging the name would mean a lot of work. Is there any other way.

Please help.

 
I dont think so. the only thing I can suggest is to download ultraedit ( ). it has a built-in search and replace command that will parse all the files in one directory. a very powerful tool! other than that, it is a really good text editor, with all the goodies of the expensive ones. (not that I am trying to market it tho)

also, if you have the same script you might use an external .js script file instead of the same js on every page.

works like this:
[ol][li]write your javascript as normal
[li]cut and paste everything inside but not including the <script> tags
[li]paste it into a new document and save it as somefile.js
[li]change your <script> tag to include the src attribute:
<script language=javascript src=somefile.js></script>
[/ol]

that should do the trick. theEclipse
eclipse_web@hotmail.com
Icq: 124408594
online.dll

AIM & MSN: robacarp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top