PDA

Click to See Complete Forum and Search --> : VB Script Question


vkallelil
May 2nd, 2001, 02:09 PM
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

CiberTHuG
May 2nd, 2001, 02:22 PM
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.


<%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.

CiberTHuG
May 2nd, 2001, 02:32 PM
'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.

monte96
May 2nd, 2001, 05:12 PM
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).

sail3005
May 2nd, 2001, 05:51 PM
Originally posted by CiberTHuG
...I'm not sure if any browser other than IE supports it

unfortunatly, nothing else at the moment does...:( :(

vkallelil
May 3rd, 2001, 07:35 AM
I'm going to try and let you all know how it works.

CiberTHuG
May 3rd, 2001, 08:24 AM
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....

sail3005
May 3rd, 2001, 06:53 PM
I retract my statment:

FORTUNATLY, only IE supports it.

DOWN WITH UNSTANDARD CLIENT SIDE SCRIPTING LANGUAGES!!!
:D :D :D