SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2010
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javascript/active server pages (asp)

    Hi all,
    I have two radio buttons to control deleting or updating of records.
    The following javascript identifies which radio button is clicked. Then information about the record is displayed when the save button is clicked.

    So, based on the client side info I'll need to determine whether to execute the update or delete statement on the server side when the save button is clicked. How can I acheive this? how can I pass the value of the radio buttons to server side asp code.
    if del_ then
    str = " Delete from ..
    elsif upd_ then
    str = " Update abc where ..."
    end if

    This is the javascript that controls the radio button clicks
    window.onload=function(){
    oRadBtns = document.getElementById('mytbl').getElementsByTagName('input');
    for(i=0; i < oRadBtns.length; i++){
    oRadBtns[i].value += oRadBtns[i].parentNode.parentNode.lastChild.innerHTML;
    }
    document.getElementById('btnSave').onclick=function(){ // my Save button
    var str = "You have selected \n\n";

    for(i=0; i < oRadBtns.length; i++) {
    if(oRadBtns[i].checked){
    str += oRadBtns[i].value+"\n";


    }
    }
    alert(str );

    My radio buttons:
    <td><input type="radio" name="action1" value="del_" />Delete</td>
    <td><input type="radio" name="action1" value="upd_" />Update</td>

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,812
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The selected value will be passed to the server in the action1 field. Exactly which action1 field it will use depends on whether you are using POST or GET with the form.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2010
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if request.Form("btnadd") <> "" then // save button
    if request.Form("action1") <> "" then // this isn't firing
    response.Write("not null")
    end if
    end if

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2010
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Never mind, I got it. Thank you for your help.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •