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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prompt on Link Gives an error

Status
Not open for further replies.

RushiShroff

Programmer
Jan 23, 2002
216
IN
I am trying to give prompt on link onClick event and then try to submit the form but it gives me an error on the line
prompt.

Code:
<tr>
            <td><%=objRs(&quot;Company_Name&quot;)%></td>
            <td align=left><a href=&quot;#&quot; onClick=&quot;alertMe('<%=objRs(&quot;Company_Id&quot;)%>')&quot;>Delete</a></td>            
          </tr>


<script language=javascript>
function alertMe(val)
{
var a,val;
//alert(&quot;Hi&quot;);
a=Confirm(&quot;Are you sure you want to delete this record ?&quot;);
if (a)
	{
	document.admin_central.pCompany_Id.value=val;
	document.admin_central.action=&quot;admin_central.asp&quot;;
	document.admin_central.submit();
	}
}
</script>
Rushi Shroff Rushi@emqube.com
&quot;Life is beautiful.&quot;
 
Use confirm() as your if condition like so:

if (confirm('Are you sure you want to delete this record?'))
{
document.admin_central.pCompany_Id.value=val;
document.admin_central.action=&quot;admin_central.asp&quot;;
document.admin_central.submit();
}

Also, confirm() should be lower case, not upper, like you had it (Confirm())

Additionally, you might make this your link instead. I think it makes for cleaner code:

<td align=left><a href=&quot;javascript:alertMe('<%=objRs(&quot;Company_Id&quot;)%>')&quot;>Delete</a></td>

:)
paul
penny1.gif
penny1.gif
 
Dear Paul,
I have just tried your suggested

td align=left><a href=&quot;javascript:alertMe('<%=objRs(&quot;Company_Id&quot;)%>')&quot;>Delete</a></td>

But it does not seems to be working..

btw THANKS FOR THE &quot;confirm&quot; instead if &quot;Confirm&quot;
Rushi Shroff Rushi@emqube.com
&quot;Life is beautiful.&quot;
 
What does the resulting HTML look like?

Should look like this:

<a href=&quot;javascript:alertMe('9');&quot;>Delete</a>

This method does work.

:)
paul
penny1.gif
penny1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top