PDA

View Full Version : submitting a form VIA link


tyler_w
10-06-2004, 06:50 PM
OK, Im having a really frustrating lack of action..
Here's what I've got.
A form with a whole bunch of search options that submits via POST, back to the same form. It's got a 'Submit' button.
The ASP code picks up the form, generates an SQL statement, and opens recordset.

What I want to do, is divide up the records returned by a 'results/page' input and 'next'/'previous' links.

Everything *would* be working fine, except for one tiny problem... It doesn't work.
Here's the (relevant) code, this is done is ASP, btw.

'generate next url
nextURL = "listBook.asp?op=search&start=" + cstr(RecordStart + RequestsPerPage)
'write link to page
response.write "<a href=vbscript:void onClick=Redir('" + nextURL + "')> Next " + cstr(TotalLeft) + "</a>"

And in VBScript, the Redir sub

Sub Redir(href)
Document.listBook.action = href
Document.listBook.submit
' alert Document.listBook.action
End Sub


The alert, when uncommented, works fine and shows exactly what I want it to... BUT, the form doesn't submit. It sits there. If I try and press 'Submit' button further up on the form, it uses the action i gave it. EVERYTHING WORKS EXCEPT THE FORM SUBMITTING via the Redir Sub. very frustrating.

tyler_w
10-06-2004, 09:12 PM
How's this for messed up?

I tried something new, holding 'shift' when I press the Next link. A new window opens up with 'vbscript:void' as the address and the form now sets the action AND submits.

To clarify, pressing 'Next' normally will do nothing but set the ACTION property of the form. Holding down shift submits the form at the cost of a useless popup.

What the crap.

tyler_w
10-06-2004, 09:16 PM
a HA!

OK, so I changed a link to <a href=# ... >
and now it seems to work.

Apparently if you use vbscript:void all submits will be canceled? Weird.

Thanks for nothing board peeps
I figured this one out solo.