View Full Version : Opening up a page based on a select list
JustAsking
10-16-2002, 03:37 AM
Hi,
Link to zip file with files I am using (http://www.build.qld.gov.au/files.zip)
I will try to example as best I can what I am trying to do.
Index.asp includes a number of select list boxes where a user can either view a particular page or have the ability to edit the page. Editing of the page is done using editor.asp. The first tab 'corporate plan' works fine being able to edit the page (to edit corporate plan pass=temp, user=temp).
I am trying to do the same functionality with the other tabs but using select list boxes (both double and single). What I am having trouble with is how am I able to select an option in a list and then depending on that option pass it through to editor.asp and open up that page for editing while also checking the username and password for that page in the database.
So for example - I click on the 'business plan' tab select 'Building Division' from the list, then enter in a username and password, click 'edit business plan' button. This fires editor.asp checks the username and password and if correct opens that business plan for editing.
I hope I have explained myself correctly. I would appreciate if anyone could help me out. Greatly appreciated :)
JustAsking
10-17-2002, 03:22 PM
Does anybody have ideas in relation to the above issue, or have I failed to explain my request for help correctly? :eek:
ksridhar69
10-17-2002, 10:20 PM
This will solve your problem. Let me know
<FORM ACTION="test.asp" METHOD="POST" Name="b" >
<tr>
<td height="35" colspan="3">
<select name="site_nbr1" onchange="document.b.submit();">
<option value="" selected>All States</option>
<option value = "al">Alabama</option>
</select>
</td></tr></form>
Hy justasking,
did the previous post solve your problem (can't immagen it did, buth who am I)
I for one don't understand what you're trying to do or what isn't working.
Do you want to check against your database if the user entered the correct pasword + if he has the right permissions to enter/edit/delete the page ? I think you want to create a sort of permission-system were each user gets permissions for specific options on speciffic pages. Is so, let me know (my response could take some days because i'm goïng away till monday. i'll be around for another six hours or so.)
Please clarify so we can, help you further.
BigDaddy
10-18-2002, 03:19 PM
From your initial form, you need to pass a hidden value of pagetype. In the second page, after doing the checklogin, do an if statement to see which pagetype was being passed to it. For each pagetype, call a different function or sub that will then display whatever you're trying to give the user.
I don't have time right now to write this for you as an example, but if you haven't gotten an answer, I should be able to post something later tonight, or tomorrow morning.
whammy
10-19-2002, 03:22 AM
I'm with raf... I initially didn't answer your post because it's not very clear.
Can you explain step-by-step what it is you're trying to accomplish? i.e.:
1. User logs in, stays logged in, then I redirect them depending on the selection they choose in a dropdown box.
2. User selects something in a dropdown box, but if they are not logged in, they are required to login before accessing the page.
etc.
It sounds like BigDaddy has given more time to perusing your .zip file contents, so he may have the better solution. But when you post a question, it does help to be a little more specific (not in code, but in ideas).
I would first require someone to login, then give them (according to their login information) the appropriate "access levels" and only display the information that is "safe" for that "access level"... if you get my drift... it sounds like raf and I may have the same ideas of the problems you may be experiencing.
If I read your post correctly, you're asking someone to verify their password, etc. after you've already given them the same choices as someone who may have logged in as a "guest". ?!?
If that IS the case, in ASP you could use Scripting.DictionaryObject (especially in conjunction with session variables), or a database, or even cookies with keys to make sure that only the people with the appropriate "access level" would ever SEE this information.
:D
JustAsking
10-20-2002, 01:43 AM
Hi peeps, I apologise not expalining myself correctly in the first place. Sometimes you know what it is you want to do in your head, but can't always expalin it on paper.
I will address Whammy's post seeing it includes the previous responses as well.
I think BigDaddy has got the right idea, so BigDaddy, if you could supply an example of some code, I could try it and see if that works for me.
Otherwise:
The user has 2 options:
1. Choose an option from a dropdown box, and selects "view this page (does not require a password), anyone can do this.
2. Choose an option from the same dropdown box, but selects "edit this page (will require to enter a username and password, and if correct gives access to edit page).
Posted by Whammy
I would first require someone to login, then give them (according to their login information) the appropriate "access levels" and only display the information that is "safe" for that "access level"... if you get my drift... it sounds like raf and I may have the same ideas of the problems you may be experiencing.
I had not considered trying this, so would I possibly be able to be given an example of how to code this, preferably by using my code (although this would take time I understand), otherwise some generic code and I will try to adapt it to my code.
I hope this clears up any confusion, thanks for helping anyway...
BigDaddy
10-20-2002, 04:39 AM
OK. This is a simple example of what I meant. I did not realize that you were selecting from possibly more than one select box on each page, but you can probably modify my idea to fit whatever you're looking for.
My outline is simple:
1. dim variables, get them from request.form, etc.
2. Do your database stuff
3. call your header sub to display the header info.
4. Check the password with username. If the user matches with the password, you go to step 5, otherwise, you say "sorry, pal" and go to 6.
5. A select case statement, which takes the variable "business" from the select box on the previous page and calls the appropriate sub, based on what you want to do. Each sub will be its own page, and is only displayed if this is the one being passed. I would then pass a hidden field with the page type if you want to submit this page back to itself. when it gets to step 5, it will then display the right sub.
6. call the footer sub.
*** You might say, "Gee, BD...you're way off of what I wanted....". In which case, sorry to get your hopes up. :) Hope this helps, though.
I would also recommend whammy's idea of multi-level authorization. You can just add a field to your database table, and just pull their authorization level when you check the password. If it's >= what you need to access that sub, then great. Just do a comparison at the start of each sub.
JustAsking
10-21-2002, 02:52 AM
BigDaddy,
Thanks for the help. One question for you though. In relation to the code as per below see my *** comments
sub esbus()
%>
This is the esbusinessplan page.
*****************
Can I have the code for this page coming from esbusinessplan.htm rather than insert the html code in here.
*****************
<%
end sub ''''''''''''' end esbusinessplan
Finally for everyone, just thinking of different things here. Can I use a hidden dropdown box in a form. So user chooses a selection from a dropdown box and this selection will change the value of the other hidden dropdown box?
BigDaddy
10-21-2002, 02:59 AM
You could do an include statement to pull that page in (You'd have to make it esbusinessplan.asp, though) or you could do a redirect to it.
whammy
10-21-2002, 04:19 AM
As for using a hidden field, yeah you can do that... look here:
<html>
<head>
<script language="JavaScript" type="text/javascript">
<!--
function savefoc(fldname){
// alert(fldname);
document.form1.savefocus.value = fldname;
}
// -->
</script>
</head>
<body>
<form name="form1" action="savefocus.htm" method="get">
<input type="text" name="field1" onfocus="savefoc(this.name)" /><br />
<input type="text" name="field2" onfocus="savefoc(this.name)" /><br />
<input type="text" name="field3" onfocus="savefoc(this.name)" /><br />
<input type="hidden" name="savefocus" value="" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
JustAsking
10-24-2002, 07:39 AM
I have used the solutions that have been provided above and have been able to get most of it working. I need help with a problem though.
I am using a select case to work out which document needs to be edited that the user choose from a dropdown box.
select case business
case bdbusinessplan
call bdbus()
case esbusinessplan
call esbus()
case erbusinessplan
call erbus()
case fitbusinessplan
call fitbus()
case goprintbusinessplan
call goprint()
case impbusinessplan
call impbus()
case iabusinessplan
call iabus()
case lcbusinessplan
call lcbus()
case phrbusinessplan
call phrbus()
case psbusinessplan
call psbus()
case qbuildbusinessplan
call qbuild()
case qfleetbusinessplan
call qfleet()
case qpbusinessplan
call qpbus()
case sdsbusinessplan
sdsbus()
end select
Variable 'business' is the value of the dropdown box from the previous page. Depending on which selection was made will depend which call function is used.
The code seems to be geeting stuck on the first select case. For example, if the function call sdsbus() is supposed to be invoked, the function call bdbus() is still envoked. It doesn't seem to be calling the right select case based on the dropdown box.
Here is the dropdown box code:
<form name="business" action="authorise02.asp" method="post">
<p><select name="businessplan" size="1">
<option value="bdbusinessplan.htm">Building Division</option>
<option value="esbusinessplan.htm">Executive Services</option>
<option value="erbusinessplan.htm">External Relations</option>
<option value="fitbusinessplan.htm">Finance and Information Technology</option>
<option value="goprintbusinessplan.htm">Goprint</option>
<option value="impbusinessplan.htm">Infrastructure and Major Projects</option>
<option value="iabusinessplan.htm">Internal Audit</option>
<option value="lcbusinessplan.htm">Legal and Contractual</option>
<option value="phrbusinessplan.htm">Planning and Human Resources</option>
<option value="psbusinessplan.htm">Project Services</option>
<option value="qbuildbusinessplan.htm">QBuild</option>
<option value="qfleetbusinessplan.htm">QFleet</option>
<option value="qpbusinessplan.htm">Queensland Purchasing</option>
<option value="sdsbusinessplan.htm">SDS</option>
</select></p>
<p><input type="button" value="View/Print Business Plan" onClick="window.location=businessplan.options[businessplan.options.selectedIndex].value"></p>
<p>username: <input type="text" name="username" size="20"></p>
<p>password: <input type="password" name="password" size="20"></p>
<p><input type="submit" value="Edit Business Plan"></p>
</form>
The pages can be viewed at: http://www.build.qld.gov.au/zcorporate/index.asp
http://www.build.qld.gov.au/zcorporate/authorise02.asp
whammy
10-25-2002, 12:37 AM
If business is a string (which I assume it is), you also need to do this:
case "bdbusinessplan"
Other than that, I see no reason why it shouldn't work... and if I'm right, the reason it's getting stuck on the first one is you have no case else in the code, since nothing matches. :)
JustAsking
10-25-2002, 01:13 AM
Thanks Whammy that did the job - don't know why I didn't try/think of that. Guess that's why you have 1000+ useful posts and I don't. :D :thumbsup:
whammy
10-25-2002, 01:15 AM
I'm glad that I could be of help - and thanks for the compliment! :cool:
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.