|
-
Nov 19th, 2001, 12:00 PM
#1
Thread Starter
Evil Genius
javascript one
1) Page1.htm - contains only a submit button control.
2) User clicks this & sends page1 to Page2.asp
3) Page3.asp contains <select> and hidden field.
4) User selects from the combobox.
5) This selection text is placed into the hidden field.
6) The page then is then automatically submitted - to itself.
4-6 keep going in a loop, every time the user chooses an entry, the page reloads. Now when the page loads, the combobox shows the default first entry. What I'd like is for this to show trhe last selected entry. 
What I've done is set up a body_onload event which loops through all the entries in the combobox and selects the one which matches the request pages hidden text field's text:
Code:
function SelectChosenGam() {
if (request.form("hidChosen") != "") {
var intCounter;
for(intCounter=0; intCounter<theForm.combo1.options.length; intCounter++) {
if (theForm.combo1.options[intCounter] == Request.Form("hidChosen")) {
theForm.combo1.selectedIndex = intCounter;
}
}
}
}
This works fine when the page2.asp page is submitting to itself. But then I realised that page1.htm submits to this page also & doesn't have the hidden field. How can I trap for this please ?
Last edited by alex_read; Nov 20th, 2001 at 04:57 AM.
-
Nov 19th, 2001, 12:35 PM
#2
Hyperactive Member
I couldn't make head nor tail of that!
Heres how I'd do it
<select name="select">
<option value="one" selected>one</option>
<optionvalue ="two" >two</option>
</select>
the above shows option one selected!
Use asp to write out the combo box!
and put a variable inplace of the selected
eg
dim one as string
print '<option value="one"' & one & '>one</option>
so all you do now is test what you got for your input, if you got a one then simply do
one = "selected"
print '<option value="one"' & one & '>one</option>
I'm not familiar with ASP so I don't know the syntax, but this is an adapted method of one I use for Perl!
If you need a more detailed explanation you'll have to wait until tommorow!!
-
Nov 20th, 2001, 05:00 AM
#3
Thread Starter
Evil Genius
Hi Progressive - thanks for that. You're right, I didn't explain that one too well, so had another attempt.
Please look again at the above as I've changed the wording of the question. It fails on the first if (request.form("hidChosen") != "") { line as it can't find the hidChosen field of page1.
Thanks !
-
Nov 20th, 2001, 05:11 AM
#4
Hyperactive Member
try this
Code:
onload="setTimeout('SelectChosenGam()', 1000)"
The onload event is not a particulary good method, when you are referencing form elements, and layers. As when the onload event fires these elements have not always been set!
This may be what is causing you problems!
Let me know how you get on!
-
Nov 20th, 2001, 05:16 AM
#5
Thread Starter
Evil Genius
I've stuck a hidden field in the page1.htm - this on'es been bugging me so though not too professional, I thought sod it ! 
Thanks for the suggestions
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|