Forums
This topic is locked
Select menu and request.querystring puzzle
Posted 07 Mar 2007 01:56:26
1
has voted
07 Mar 2007 01:56:26 Javier Castro posted:
Hi All,I'm Working with Dreamweaver 8, ASP Classic.
I have an Insert Record form. The form has a Select menu, with categories,below there are text fields for content.
when the form is sunmitted it reloads to the same page with an empty form, to input another record.
My problem:
I want to be able to select a category from my menu, fill the text field and submit and when the page loads again my previous selection should stays the same, unless I decide to change it.
I did something like this but with a text field on a search form.
Any help will be very much appreciated. I'll call you uncle. <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
Javier
Replies
Replied 07 Mar 2007 11:50:55
07 Mar 2007 11:50:55 Lee Diggins replied:
Hi Javier
Have you tried setting the value of your form textfield items to the value submitted by the form - request.form("formItemName" or request.querystring("formItemName"?
For the select menu, you'll need to work with it a little differently, here's an example below:
<pre id=code><font face=courier size=2 id=code> <select name="select">
<%
While (NOT Recordset1.EOF)
%>
<option value="<%=(Recordset1.Fields.Item("column_data_id".Value)%>" <%If (Not isNull(Request.Form("select")) Then If (CStr(Recordset1.Fields.Item("column_data_id".Value) = CStr(Request.Form("select")) Then Response.Write("SELECTED" : Response.Write(""%> ><%=(Recordset1.Fields.Item("column_data_name".Value)%></option>
<%
Recordset1.MoveNext()
Wend
If (Recordset1.CursorType > 0) Then
Recordset1.MoveFirst
Else
Recordset1.Requery
End If
%>
</select> </font id=code></pre id=code>
What's happening here is the value field in the drop-down is being compared to the value submitted by the form's drop-down field, if there's a match then the attribute SELECTED is added to the drop-down and so shows as selected.
I don't have DW8 so I can't give you a actual DW8 example, this one is from DWMX
Sharing Knowledge Saves Valuable Time!!!
~ ~ ~ ~ ~ ~
<b>Lee Diggins</b> - <i>DMXzone Manager</i>
<font size="1">[ Studio MX/MX2004 | ASP -> VBScript/PerlScript/JavaScript | SQL | CSS ]</font>
Have you tried setting the value of your form textfield items to the value submitted by the form - request.form("formItemName" or request.querystring("formItemName"?
For the select menu, you'll need to work with it a little differently, here's an example below:
<pre id=code><font face=courier size=2 id=code> <select name="select">
<%
While (NOT Recordset1.EOF)
%>
<option value="<%=(Recordset1.Fields.Item("column_data_id".Value)%>" <%If (Not isNull(Request.Form("select")) Then If (CStr(Recordset1.Fields.Item("column_data_id".Value) = CStr(Request.Form("select")) Then Response.Write("SELECTED" : Response.Write(""%> ><%=(Recordset1.Fields.Item("column_data_name".Value)%></option>
<%
Recordset1.MoveNext()
Wend
If (Recordset1.CursorType > 0) Then
Recordset1.MoveFirst
Else
Recordset1.Requery
End If
%>
</select> </font id=code></pre id=code>
What's happening here is the value field in the drop-down is being compared to the value submitted by the form's drop-down field, if there's a match then the attribute SELECTED is added to the drop-down and so shows as selected.
I don't have DW8 so I can't give you a actual DW8 example, this one is from DWMX
Sharing Knowledge Saves Valuable Time!!!
~ ~ ~ ~ ~ ~
<b>Lee Diggins</b> - <i>DMXzone Manager</i>
<font size="1">[ Studio MX/MX2004 | ASP -> VBScript/PerlScript/JavaScript | SQL | CSS ]</font>
Replied 07 Mar 2007 17:47:33
07 Mar 2007 17:47:33 Javier Castro replied:
Thanks for the reply Lee,
I understand your suggestion and I tried doing that: first by creating a request.queryString on the bindings panel and applying it to my select menu.
Also by Creating A request.form. Unfortunately, it did not work. I used the code you sent and noticed that DW8 modified a little bit the code by ading some quotation marks. This example uses the Request.QueryString.
<option value="<%=(rsIssueNumber.Fields.Item("intIssueID".Value)%>" <%If (Not isNull(Request.QueryString("mselect")) Then If (CStr(rsIssueNumber.Fields.Item("intIssueID".Value) = CStr(Request.QueryString("mselect")) Then Response.Write("selected=""selected""" : Response.Write(""%> ><%=(rsIssueNumber.Fields.Item("IssueDate".Value)%></option>
I am looking for a work around right now. If you have other ideas, please fire them up to me..
Cheers,
Javier
I understand your suggestion and I tried doing that: first by creating a request.queryString on the bindings panel and applying it to my select menu.
Also by Creating A request.form. Unfortunately, it did not work. I used the code you sent and noticed that DW8 modified a little bit the code by ading some quotation marks. This example uses the Request.QueryString.
<option value="<%=(rsIssueNumber.Fields.Item("intIssueID".Value)%>" <%If (Not isNull(Request.QueryString("mselect")) Then If (CStr(rsIssueNumber.Fields.Item("intIssueID".Value) = CStr(Request.QueryString("mselect")) Then Response.Write("selected=""selected""" : Response.Write(""%> ><%=(rsIssueNumber.Fields.Item("IssueDate".Value)%></option>
I am looking for a work around right now. If you have other ideas, please fire them up to me..
Cheers,
Javier
Replied 07 Mar 2007 23:55:43
07 Mar 2007 23:55:43 Lee Diggins replied:
Hi Javier
The only difference I can find is:
Response.Write("selected=""selected"""
Instead of:
Response.Write("SELECTED"
All I can suggest at the moment is to try with this code, if still no success, can you post the whole page code or email it to me.
Sharing Knowledge Saves Valuable Time!!!
~ ~ ~ ~ ~ ~
<b>Lee Diggins</b> - <i>DMXzone Manager</i>
<font size="1">[ Studio MX/MX2004 | ASP -> VBScript/PerlScript/JavaScript | SQL | CSS ]</font>
The only difference I can find is:
Response.Write("selected=""selected"""
Instead of:
Response.Write("SELECTED"
All I can suggest at the moment is to try with this code, if still no success, can you post the whole page code or email it to me.
Sharing Knowledge Saves Valuable Time!!!
~ ~ ~ ~ ~ ~
<b>Lee Diggins</b> - <i>DMXzone Manager</i>
<font size="1">[ Studio MX/MX2004 | ASP -> VBScript/PerlScript/JavaScript | SQL | CSS ]</font>
Replied 08 Mar 2007 05:23:02
08 Mar 2007 05:23:02 Javier Castro replied:
Hi Lee,
I'll have to get back to this at another time. But i'll play with the code you suggested and test it again on a test site not on my live material.
Thanks a bunch.
I'll have to get back to this at another time. But i'll play with the code you suggested and test it again on a test site not on my live material.
Thanks a bunch.