![]() |
| |||||||
| Sponsored Links |
![]() |
| | LinkBack (1) | Thread Tools | Display Modes |
#1
| ||||
| ||||
| Hi All, I need help with the following, I get an "Object Expected" error when page is loaded and it doesn't load the textbox, when I have the lines that I have commented out, it seems to work but continue to get the error if I try to pull in the recordset. Code: objectType = 0;
function changeFormObject() {
var object_span = "";
var change_span = "";
if (objectType != 1) {
object_span += ("<input type='text' name='PartNum' />");
change_span += ("Pick from List!");
objectType = 1;
}
else {
object_span += ("<select name='PartNum'>");
object_span += ("<option value=''> - SELECT - </option>");
<%
'strSQL = "Select PartNum from vwPartNumbers"
'set rs = conn.execute(strSQL)
'Do while not rs.eof
' response.write ("object_span += ""<option value='" & rs("PartNum") & "'>" & rs("PartNum") & "</option>""")
' rs.movenext
'Loop %>
object_span += ("</select>");
change_span += ("change to textbox.");
objectType = 2;
}
document.getElementById("object_span").innerHTML = object_span;
document.getElementById("change_span").innerHTML = change_span;
}
Code: <BODY onload="changeFormObject()">
<TR>
<TD>Part Number:</TD><TD><span id="object_span"></span> <span id="change_span" onclick="changeFormObject()" onmouseover="this.style.cursor='pointer';"></span>
</TD>
</TR>
Last edited by richyrich; May 6th, 2008 at 12:00 PM. Reason: Removed [SOLVED] from title |
| Sponsored Links |
|
#2
| ||||
| ||||
| This line looks queer: response.write ("object_span += ""<option value='" & rs("PartNum") & "'>" & rs("PartNum") & "</option>""") shouldn't the += be outside the quotes? |
|
#3
| ||||
| ||||
| queer...hehe ok, i tried this but get syntax error on the = sign. Is this what you mean? Code: response.write (object_span += ""<option value='" & rs("PartNum") & "'>" & rs("PartNum") & "</option>"")
|
|
#4
| ||||
| ||||
| I admit, I took a quick look at it before leaving yesterday. Lemme look it over again when I get a chence if no one else jumps in. [EDIT] OK, it looks like you are attempting to build the HTML for a select tag into the variable object_span. If so, then I wonder about the response.write in your while loop. Wouldn't that cause your option tags to be written out before the select tag that contains them? If I'm on the right track, then I think the line in your loop should be just: object_span += "<option value='" & rs("PartNum") & "'>" & rs("PartNum") & "</option>" The HTML for the select is written out later in your snippet document.getElementById("object_span").innerHTML = object_span; Not sure if this solved the Object Expected error, but it should do something different at least. Or was the Response.write for debugging purposes -- if so I'm on the wrong track here. Last edited by Wolffy; April 19th, 2008 at 01:10 PM. |
|
#5
| ||||
| ||||
| Try changing this line:- Code: response.write ("object_span += ""<option value='" & rs("PartNum") & "'>" & rs("PartNum") & "</option>""") to:- Code: response.write (vbcrlf&"object_span += ""<option value='" & rs("PartNum") & "'>" & rs("PartNum") & "</option>""") Last edited by richyrich; April 20th, 2008 at 06:48 AM. |
|
#6
| ||||
| ||||
| Thanks Wolffy and Richyrich for the reply. ![]() The solution Richyrich provided seem to be the trick. It is working, just seems a little slow. I have to work on the select statement now because it seems like I'm getting some weird results but that's something different. Do you guys know if this is how you would pull the data for the list? I'm just wondering if there is another way to still get the same results. I'm going to be attempting to allow either to enter thru the textbox or when a selection is made thru the list, it will populate some of the other fields. Cheers! |
|
#7
| ||||
| ||||
| Personally, I tend to render the dropdown to the page as normal and use visibility and display styles to hide / show it. Do you mean the speed of the JS change or the speed of the page load? If it's the JS change, maybe try the visibility/display solution. Something like:- Code: <select id="PartNum" name="PartNum" style="display:none;visibility:hidden;">
Then in JS
document.getElementById('PartNum').style.display='block';
document.getElementById('PartNum').style.visibility='visible';
|
|
#8
| ||||
| ||||
| @rr - why not just display:none? I'm confused on why both style attributes would be needed. From what I understand, display:none does not render the HTML to the page. visibility:hidden will make the element not visible, but it still occupies the same space. But it wouldn't appear that would be needed if display:none is set.
__________________ jmurrayhead If you agree with me... click the icon! If my post solved your problem, click the button in the lower right-hand corner of the post.If you like it here...throw us a few bones to help support us. Join our Folding team: DeveloperBarn Folding |
|
#9
| ||||
| ||||
| I think I had cross browser problems in the past just using visibility, so force of habit I use both.... I think in FF an item with visibility:hidden doesn't use up space, whereas in IE, it does. It just stems from problems I had in the past, but yes, you could just use visibility.... ![]() Was just giving both options... |
|
#10
| ||||
| ||||
| Hi Richyrich, It's slow when I click on "Pick from List". I'll check out your suggestion. Thanks! |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
LinkBacks (?)
LinkBack to this Thread: http://www.developerbarn.com/javascript-programming/136-textbox-list-help.html | ||||
| Posted By | For | Type | Date | |
| Textbox or List help - JavaScript Programming | This thread | Refback | April 18th, 2008 08:23 PM | |