Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 05-03-2004, 07:28 AM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,486
sde is on a distinguished road
getting the value of a select box to confirm delete.

javascript is definately one of my weak points. i have a select box with the options of 'edit' and 'delete'.

i need to run a confirm javascript only if 'delete' is selected.

here's the javascript:
Code:
<SCRIPT type="text/javascript">
<!--
function verifyDelete(id)
{
  if(confirm("Are you sure you want to delete this item?"))
    return true;
  else
    return false;
}
-->
</SCRIPT>
and here's my form:
Code:
<form method=post action=http://codenewbie.com>

<select name=modify>
<option value=edit32>edit</option>
<option value=delete32>delete</option>
</select>
<input type=submit name=submit value=submit onClick="return verifyDelete()">

</form>
__________________
Mike
sde is offline   Reply With Quote
Old 05-03-2004, 07:36 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,486
sde is on a distinguished road
i guess this isn't a real good question .. ok, here is my question..

how can i send the value of 'modify' in the arguments of my verifyDelete() function?

once i can do that, it will be easy to check for 'delete' in the js function before i call the confirm().
__________________
Mike
sde is offline   Reply With Quote
Old 05-03-2004, 08:40 AM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,486
sde is on a distinguished road
solution:
Code:
<HTML>
<head>

<SCRIPT type="text/javascript">
<!--
function verifyDelete(modify)
{  
  if(modify.value == "delete")
  { 
    if(confirm("Are you sure you want to delete this item?"))
      return true;
    else
      return false;
  }
  else
  {
    return true;
  }
}
-->
</SCRIPT> 
</head>

<BODY>
<form method=post action=http://codenewbie.com onSubmit="return verifyDelete(this.modify);">

<select name=modify>
<option value=edit>edit</option>
<option value=delete>delete</option>
</select>
<input type=submit name=submit value=submit>

</form>
</BODY>
</HTML>
__________________
Mike
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP:drop down box prob RusH MS Technologies ( ASP, VB, C#, .NET ) 0 10-22-2004 12:38 AM
Nested subquery within the Select clause jsze Everything SQL ( MySQL, MSSQL, DB2, Postgre, Oracle, etc...) 6 10-12-2004 10:23 AM
drawing a selection box sammy HTML, XML, Javascript, AJAX 1 06-18-2004 10:45 AM
what language is this? sde All Other Coding Languages 10 05-25-2004 03:57 PM
dynamic select menues sde HTML, XML, Javascript, AJAX 5 02-15-2003 09:05 AM


All times are GMT -8. The time now is 02:19 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting