Results 1 to 8 of 8

Thread: VB Script Question

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    US, PA
    Posts
    79

    VB Script Question

    Hi all,

    I'm new to Asp page. I have an Asp page which displays the results of a query from SQL server. This works good. The data I'm displaying is in a table format.

    What I want to do, is to have a command button at the end of each row. So when the user clicks on the button a different asp page should open up with text boxes where I could change or add value, and then save it to the database (in SQL Server).

    How do I create the command button, so that it is linked to a particular row, and when the values are changed/added how does it update that particular row.

    I hope I'm explaning myself clearly.

    Thanks,

    Reggie

  2. #2
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Reggie,

    You are explaining yourself just fine. It is a very involved kind of answer, though.

    I would probably put a little bit of JavaScript on the page and anchors instead of form submit buttons. Let me show you.

    Code:
    <%Randomize%>
    
    <form name='Update' method='POST' action='NextPage.asp'>
    
    <%
      'ASP Example
    
      'Do SQL Query here and parse data like you want
    
      'Step through each row of the SQL data and put it in the table
      'Write this as the last data element
      Response.Write("<a href='JavaScript:UpdateRow(\"" & i & "\");>Update</a>");
      'Do this were i is the current row that may need to be updated.
    %>
    
    <input type='hidden' name='whichRow'>
    
    </form>
    
    <script language='JavaScript>
      function UpdateRow ( RowNum ) {
        document.Update.whichRow.value = RowNum
        document.Update.submit();
      }
    <script>
    Anyway... I'm sure there is a solution that doesn't involve bringing in another technology (JavaScript), but it is a very quick and easy one.

    Anyway, on the next page you can ask what Request.Form("whichRow") is.

    Another solution would be to create different submit buttons for each row, but that can be cumbersome.

    I hope I made sense.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  3. #3
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    'Course, it dawns on me that you don't have to use JavaScript as your client side script language. In theory you can use VBScript, but I'm not sure if any browser other than IE supports it. Oh... yeah, you can use JScript, but what's the point of mentioning that.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  4. #4
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Another option is to put a form on each line with a submit on each line and put the record's id value into a hidden textbox. You can do this in a loop and all the forms and submit buttons can have the same name. ASP will keep track of which one was clicked by where it is (Which form tag it falls between).
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  5. #5
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    Originally posted by CiberTHuG
    ...I'm not sure if any browser other than IE supports it
    unfortunatly, nothing else at the moment does...

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    US, PA
    Posts
    79

    Thanks you all

    I'm going to try and let you all know how it works.

  7. #7
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Originally posted by sail3005
    unfortunatly, nothing else at the moment does
    Unfortunately? I'd have to disagree. It would be a good thing when VBScript (and JScript) are depreciated. They don't add anything to client-side scripting technology, I'm sure they slow down standardization efforts, and they make browsers larger because they have to maintain client-side engines to parse the different languages.

    But anyway....
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  8. #8
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    I retract my statment:

    FORTUNATLY, only IE supports it.

    DOWN WITH UNSTANDARD CLIENT SIDE SCRIPTING LANGUAGES!!!

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

Posting Permissions

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



Click Here to Expand Forum to Full Width