| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#31
|
||||
|
||||
|
Quote:
It is not essential, it is just one way to do it. You can just as easily use: Code:
<form id="f1"> ... <input type="text" name="td1" value="Something" /> ... Code:
alert(document.getElementById('f1').td1.value);
// or
alert(document.getElementById('f1').elements['td1'].value);
__________________
Support requests via PM will be ignored! |
|
#32
|
|||
|
|||
|
Code does not work if query results contain " character
Hi - I tried the code today and it works great until I try and populate the drop down boxes with fields that contain the " character - does anyone have a fix for this?
Cheers! |
|
#33
|
||||
|
||||
|
this is more of HTML problem - quote in the value generate such HTML:
Code:
<option value="I am "strong" today">1</option> the HTML define the option value as "I am " only and there's no direct fix for that. instead, replace the quotes when displaying: Code:
<option value="<%=Replace(objRS("fieldname"), Chr(34), """)%>">1</option>
this will generate such HTML: Code:
<option value="I am "strong" today">1</option> that will be passed correctly, and you can parse the quotes back using Replace again: Code:
strData = Replace(Request("name"), """, Chr(34)))
|
|
#34
|
|||
|
|||
|
Reduce size of list?
Hello
I have got this working without any trouble so first of all thank you for helping the first person cause it helped me! However, the dropdown menu contains a lot of options and when you click on it, 30 of them display as the drop down menu expands to the top of the screen. Is there any way to reduce how many items appear in the list at one time? Thanks for your help, Regards, Gareth |
|
#35
|
||||
|
||||
|
hello Gareth and welcome to aspfree!
![]() the only thing that I'm aware of is the "size" attribute: Code:
<select name="myselect" size="3"> if that's not what you want, please post new thread in the HTML Forum and hopefully someone will be able to help. |
|
#36
|
|||
|
|||
|
Thanks for the welcome and for the reply. Unfortunately i do not have a:
Code:
<select name="myselect" size="3"> in my code because the drop down menus are created by using the function buildLinkedList which uses asp and javascript as in post #2 of this thread. I assume because of this it should not be posted in the HTML forum? Does anyone else have any other ideas? Thanks again, Gareth Quote:
|
|
#37
|
||||
|
||||
|
just add the proper HTML to the ASP code. look where the combo box is generated,
and in there add the size. to find this, open the ASP source code with Notepad. click F3. search for "<select" (without quotes) and you should find the place where it's generated. change the "<select" and make it "<select size=3" instead, and it should change the final HTML output. |
|
#38
|
|||
|
|||
|
Shadow Wizard,
Thanks for your help... for some reason i couldnt see it! I have made the alterations to the code and it resulted in the box changing from a drop down list to a scrolling list. Is there anything else i can try as i really want it to be a drop down list? Thanks, Gareth Quote:
|
|
#39
|
||||
|
||||
|
Quote:
Quote:
as far as I know, it's not possible to change the amount of options displayed. however I'm not HTML guru so maybe there is way - post in the HTML Forum question like "how to change the amount of options displayed in combo" and hopefully someone do know of some way for this - if it's possible, it involve HTML or CSS code that you can insert into the ASP code as I explained before. |
|
#40
|
|||
|
|||
|
Shadow,
Thanks once again. I will post there and keep my fingers crossed... although I am starting to like the look of the list being a scroll box as it leaves a space which i can fill with another search option. If the company likes the look of it too then I will leave it as a scroll box and my problem is solved! Thanks for your time, Regards, Gareth Quote:
|
|
#41
|
|||
|
|||
|
How do I pass my selected variables to another page?
This works GREAT! It's the only one of these that I've found that I got to work.Now, how do I pass the variables that have been selected to another page? ![]() |
|
#42
|
||||
|
||||
|
just change the action of the form to the URL of the other page.
|
|
#43
|
|||
|
|||
|
Re: how do I pass the variables that have been selected to another page?
Quote:
---------------------------------------------- I work mostly in VBScript and so I'm having problems determining how to gather my variables and put them into a querystring to pass in my url to another page. Here's my code: ---------------------------------------------- Code:
'Construct SQL statement
strSQL = "SELECT DISTINCT x.LoanTypeKey, x.type, x.amountKey, y.LoanTypeKey, y.Type, y.amountKey, y.amount FROM tblLoan_rates AS x INNER JOIN tblAmount AS y ON x.amountkey = y.amountkey ORDER BY x.Type ASC, y.amountkey ASC;"
'execute SQL statement to return a recordset
objRS.Open strSQL
'build an array from the recordset using GetRows
arrRS = objRS.GetRows
'close the recordset
objRS.close
set objRS = nothing
'each of the fields from the sql statement will be referenced in the function call
'by their numeric position, starting from 0, so in this example:
'(x) LoanTypeKey = 0
'(x)Type = 1
'(x)AmountKey = 2
'(y) LoanTypeKey = 3
'(y)Type = 4
'(y)AmountKey = 5
'(y)Amount = 6
%>
<style type="text/css">
.width150 {
width: 150px;
}
</style>
<!--<form id="testform" method="get" action="loan_terms.asp?loantypekey=<%=objRS("LoanTypeKey")%>&amountKey=<%=objRS("AmountKey")%>">-->
<form id="testform" method="get" action="loan_terms.asp?loantypekey=<%=objRS("LoanTypeKey")%>&amountKey=<%=objRS("AmountKey")%>">
<%= buildLinkedList("listLoan",0,1,1,"Select a Loan","width150","listAmount",2,6,1,"Select an Amount","width150") %>
</form>
<%
function buildLinkedList(list1name,list1value,list1text,lis t1size,list1prompt,list1class,list2name,list2value ,list2text,list2size,list2prompt,list2class)
dim strList1, i, strValue, strAssocArr, strAssocArrElem, strList2, strArray, strFunctions
'build the output for the first list
strList1 = "<select class='" & list1class & "' name='" & list1name & "' size='" & list1size & "' onchange='getList2(this);'>" & VbCrLf
strList1 = strList1 & "<option value='' selected='selected'>" & list1prompt & "</option>" & VbCrLf
for i = 0 to uBound(arrRS,2)
if arrRS(list1text,i) <> strValue then
strValue = arrRS(list1text,i)
strList1 = strList1 & "<option value='" & arrRS(list1value,i) & "'>"
strList1 = strList1 & arrRS(list1text,i) & "</option>" & VbCrLf
if len(strAssocArr) > 0 then
strAssocArr = left(strAssocArr, len(strAssocArr) - 3) & VbCrLf & ");" & VbCrLf
end if
strAssocArr = strAssocArr & "assocArray[""" & list1name & "=" & arrRS(list1value,i) & """] = new Array(" & VbCrLf
strAssocArr = strAssocArr & """"",""" & list2prompt & """," & VbCrLf
end if
strAssocArrElem = """" & arrRS(list2value,i) & """, """ & arrRS(list2text,i) & """," & VbCrLf
strAssocArr = strAssocArr & strAssocArrElem
next
strList1 = strList1 & "</select>" & "<br><br><br>" & VbCrLf
'build the output for the second list
strList2 = "<select class='" & list2class & "' name='" & list2name & "' size='" & list2size & "'>" & VbCrLf
strList2 = strList2 & "<option value=''> </option>" & VbCrLf
strList2 = strList2 & "</select>" & VbCrLf
'build the associative array to populate list 2
strAssocArr = mid(strAssocArr, 1, len(strAssocArr)-3) & ");"
strArray = "<script type='text/javascript' language='javascript'>" & VbCrLf
strArray = strArray & "var assocArray = new Object();" & VbCrLf
strArray = strArray & strAssocArr & VbCrLf
'build the javascript functions to operate the listboxes
strFunctions = "function getList2(listOptions){" & VbCrLf
strFunctions = strFunctions & " var thisform = listOptions.form;" & VbCrLf
strFunctions = strFunctions & " clearDropDown(thisform." & list2name & ");" & VbCrLf
strFunctions = strFunctions & " var newvalue = listOptions.name + ""="" + listOptions.options[listOptions.selectedIndex].value;" & VbCrLf
strFunctions = strFunctions & " fillDropDown(thisform." & list2name & ", newvalue); // fill the 2nd dropdown options" & VbCrLf
strFunctions = strFunctions & "}" & VbCrLf
strFunctions = strFunctions & "function clearDropDown(listOptions){" & VbCrLf
strFunctions = strFunctions & " for (var i = listOptions.options.length - 1; i >= 0; i--){" & VbCrLf
strFunctions = strFunctions & " listOptions.options[i] = null;" & VbCrLf
strFunctions = strFunctions & " }" & VbCrLf
strFunctions = strFunctions & " listOptions.selectedIndex = -1;" & VbCrLf
strFunctions = strFunctions & "}" & VbCrLf
strFunctions = strFunctions & "function fillDropDown(listOptions, vValue){" & VbCrLf
strFunctions = strFunctions & " if (vValue != """" && assocArray[vValue]){" & VbCrLf
strFunctions = strFunctions & " var arrX = assocArray[vValue];" & VbCrLf
strFunctions = strFunctions & " for (var i = 0; i < arrX.length; i = i + 2){" & VbCrLf
strFunctions = strFunctions & " listOptions.options[listOptions.options.length] = new Option(arrX[i + 1], arrX[i]);" & VbCrLf
strFunctions = strFunctions & " }" & VbCrLf
strFunctions = strFunctions & " } else listOptions.options[0] = new Option("""", """");" & VbCrLf
strFunctions = strFunctions & "}" & VbCrLf
strFunctions = strFunctions & "</script>" & VbCrLf
buildLinkedList = strList1 & VbCrLf & strList2 & VbCrLf & strArray & VbCrLf & strFunctions & VbCrLf
end function
%>
------------------------------ I'd like to capture the loantypekey and amountkey selected and put into a querystring to send to another form that will give results based on these selections. I'm having problems with syntax, any help with that? The URL I've used isn't working the way I've written it. Thanks in advance for any help you can provide! Last edited by Lafinboy : July 12th, 2006 at 07:33 PM. Reason: Added code block |
|
#44
|
||||
|
||||
|
indeed, your syntax is wrong.
change this: Code:
<form id="testform" method="get" action="loan_terms.asp?loantypekey=<%=objRS("LoanTypeKey")%>&amountKey=<%=objRS("AmountKey")%>">
to be this: Code:
<form id="testform" method="get" action="loan_terms.asp"> then this: Code:
<%= buildLinkedList("listLoan",0,1,1,"Select a Loan","width150","listAmount",2,6,1,"Select an Amount","width150") %>
to be this: Code:
<%= buildLinkedList("loantypekey",0,1,1,"Select a Loan","width150","amountKey",2,6,1,"Select an Amount","width150") %>
having this, the selected values will go to the page loan_terms.asp where you can read them using Request("loantypekey") and Request("amountKey") |
|
#45
|
|||
|
|||
|
Altering variable in javascript
Thank You! It worked perfectly! One more thing. I'd like to alter the output of one of the fields in the drop down box. I'm not sure where I'd put this in my code...
Here's my vbscript: <%=Replace(RS("Type"),"_"," ")%> Obviously my type field has some extra stuff in it that I don't want shown to the user. I tried to see if I could do it my sql statement but doesn't look like I can. Below is where it is in the numeric position (1)... 'each of the fields from the sql statement will be referenced in the function call 'by their numeric position, starting from 0, so in this example: '(x) LoanTypeKey = 0 '(x)Type = 1 '(x)AmountKey = 2 '(y) LoanTypeKey = 3 '(y)Type = 4 '(y)AmountKey = 5 '(y)Amount = 6 This is the only place in my code that I can see where I'm using this numeric position (loantypekey, 0,1,1)... <%= buildLinkedList("loantypekey",0,1,1,"Select a Loan","width150","amountkey",2,6,1,"Select an Amount","width150") %> Not sure where or if I can make this change to the type field...Syntax issues with javascript again... Thanks again for all of your help! Any javascript reference sites you can recommend? |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Dynamic dependant listboxes |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|