Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 7th, 2006, 01:10 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

;;;Can I do this
running the page will answer this question. Without seeing the values I have noo idea. There are not syntax errors I can see, so yes i guess so.

Im not sure you understand every line of the code you have written. The way you had it was fine - you were trying to compare values that were never going to match, this is why your selection was not sticking. your new way, is:

Request.Form("drive") going equal rst("YEAR_KEY")& " " & rst("YEAR_DRIVE_DESC")))

I illustrated a way to see the values you are comparing. Carry out this step again with your new method, are the values the same? is it sticking?

FYI: I get turned off a post very quickly if a person fails to answer questions. I do not ask these for fun, I ask them so I can assist you with a solution. You missed several in my last post.

BTW: My day is almost over.

Wind is your friend
Matt
 
Old March 7th, 2006, 02:04 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

JS is case sensitive Submit needs to be submit (something I missed) replace your function with:

function drive_onchange(Report_Drive)
{

   alert ('the value you selected is ' + (document.Report_Drive.drive.value));
   Report_Drive.submit();
}

/* here is the function you may want to ensure a selection is made
if(document.Report_Drive.drive.selectedIndex==0)
{
   alert("You must make a selection to proceed");
   document.Report_Drive.drive.focus();
   return(false);
}
*/

Also replace the method in the form tag to "post"

I have to go now. i hope you get this resolved I have run your function, it works.

Wind is your friend
Matt
 
Old March 7th, 2006, 04:54 PM
Authorized User
 
Join Date: Mar 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your help. There was some MAJOR confusion as to what 'drive' was in my code. I fixed it all. Sorry to have not replied to your questions. Below is the code which worked in the end.
I had to keep the method as Get since I had to retrieve a table below based on the values. I used QueryString instead of Form, with Form it was giving the complete opposite of what I needed! P.S. I have form validators to make sure user opts/enters. Any suggestions on how to get the text field working?

================================================== ===================

<form name="Report_Drive" action="pop_results_page.asp" method="GET" onsubmit="return Form1_Validator(this)">
<table border="0" width="80%" cellpadding="5" cellspacing="5">
    <tr>
        <td align="left">
    Enter Report Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
[t]<input type="text" size=62 style="top: 30px; left: 393px; width: 180px" maxlength=150 id=report_name name="report_name" value="<%Request.QueryString("report_name")%>" <% if (Request.QueryString("report_name"))<>"" then response.write("TEST") end if%>>
    </td></tr>
    </table>
<br>

<table border="0" width="80%" cellpadding="5" cellspacing="5">
    <tr>
    <td align="left">

    Choose a Drive Period from the list&nbsp;

            <%
                    set rst=Server.CreateObject("adodb.recordset")
                    strSQL = "SELECT * FROM POPD_FY_DRIVE"
                    Set rst=conn.execute(strSQL,,1)
            %>

        <select ID="drive" name="drive" language="javascript" onchange="return drive_onchange(Results_Report)">

        <option id=0 value=0>Select a new Drive Period...</option>
        <% do while not rst.Eof %>
        <option value="<%= rst("FY_DRIVE_ID") %>"
        <% if (cint(rst("FY_DRIVE_ID")) = cint(Request.QueryString("drive"))) then response.write " selected " end if %>> <%= rst("YEAR_KEY")& " " & rst("YEAR_DRIVE_DESC") %>
        </option>
        <% rst.moveNext
        loop %>
        </select>

    &nbsp;&nbsp;
    <input type="submit" name="RetrieveSKUs" value="RetrieveSKUs">
    </td></tr>
    </table>
</form>
 
Old March 7th, 2006, 06:15 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

No wories I am glad to be a help. no need to be sorry. In future address all questions asked and you will reach a solution quicker.

The reason I suggested use post is you were refereing to the request.form collection. Anyhow if its working how you want it, great.

;;;Any suggestions on how to get the text field working?
Short of reading thru this post again I an not aware what you problemis with your text field is, please expalin?



Wind is your friend
Matt
 
Old March 7th, 2006, 06:25 PM
Authorized User
 
Join Date: Mar 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

We already know that the input text field box (input name="report_name") is in the same form (form name="Report_Drive") as the dropdown list.

The user first enters a name in the text field, then selects a drive period from the dropdown list and hits the submit button "Retrieve SKUs"- after which a table is displayed below with relevant SKUs.

On the form being 'submitted', the text field and the dropdown should retain the values entered and chosen respectively. Dropdown already done, courtesy your help. I am now trying to retain the value in the text field box. Code is in bold in my last post above.

 
Old March 7th, 2006, 06:44 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

aggghhh I see. I think you know how to do this, its no different to the other problem you mostly solved your self. You need:

<input type="text" size="62" style="top: 30px; left: 393px; width: 180px" maxlength="150" id="report_name" name="report_name" value="<% if trim(request.QueryString("report_name")) <> "" then response.write trim(request.QueryString("report_name")) end if %>">

Comments:
You should lok into using CSS and get rid of inline styles (style="top: 30px; left: 393px; width: 180px") the benefits are massive. I wouldnt consider soeone for a job if they used in line styles - Style sheets are one of the best tools we have.

Why do you double quote some parameters and not others. Once again IMO a bad habbit.

You had:
value="<%Request.QueryString("report_name")%>"
This will never apear without a response.write or a <%= (the shortcut)

This:
<% if (Request.QueryString("report_name"))<>"" then response.write("TEST") end if%>
Was never going to write to the rendered page. It would apear inside your HTML and you would have to view the source to see it

You should get into the habbit of using the trim function around everything especially QS

HTH



Wind is your friend
Matt
 
Old March 7th, 2006, 07:10 PM
Authorized User
 
Join Date: Mar 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for all the advice.
It works, you rock!


 
Old March 7th, 2006, 07:15 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

No worries. Thats what this place is for. Please dont cross post. You run the risk of taking up twice as many peoples time as you need to.

Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to retain values of dynamic controls when page fozia_izhar .NET Framework 1.x 1 February 7th, 2007 02:32 PM
How to retain form values from dependent list ? George B Javascript 0 September 15th, 2006 03:54 PM
SOS: Retain values on Submit in Textfield,Dropdown rabbit124 Classic ASP Professional 1 March 7th, 2006 07:12 PM
Retain form values qhong Javascript 1 May 13th, 2004 02:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.