Mark Wood
asked on
adding some classic .asp code to javascript
i have a javascript slider that I want to add some classic asp to in order to control size etc.
example:
slider1.$SetScaleWidth(Mat h.min(pare ntWidth, 1040 ));
I want to be able to do the following or something similar:
slider1.$SetScaleWidth(Mat h.min(pare ntWidth, <%=rs(width")%> ));
any help will be appreciated
example:
slider1.$SetScaleWidth(Mat
I want to be able to do the following or something similar:
slider1.$SetScaleWidth(Mat
any help will be appreciated
ASKER
if I have it like this the slider stops working:
slider1.$SetScaleWidth(Mat h.min(pare ntWidth, <%=rs("width")%> ));
if I have it like this the slider will work but it isn't pulling the value from the db:
slider1.$SetScaleWidth(Mat h.min(pare ntWidth, '<%=rs(width")%>' ));
slider1.$SetScaleWidth(Mat
if I have it like this the slider will work but it isn't pulling the value from the db:
slider1.$SetScaleWidth(Mat
You just added a complete new variable with single quotes.
slider1.$SetScaleWidth(Mat h.min(pare ntWidth, <%=rs("width")%> ));
if I have it like this the slider will work but it isn't pulling the value from the db:
slider1.$SetScaleWidth(Mat h.min(pare ntWidth, '<%=rs(width")%>' ));
IF it worked without single quotes, why are you adding? My comment was about the double quotes missing for the field name, width.
Try no single quotes and double quotes for the field name. Also, view source and make sure there is actual data for <%=rs("width")%>
slider1.$SetScaleWidth(Mat
if I have it like this the slider will work but it isn't pulling the value from the db:
slider1.$SetScaleWidth(Mat
IF it worked without single quotes, why are you adding? My comment was about the double quotes missing for the field name, width.
Try no single quotes and double quotes for the field name. Also, view source and make sure there is actual data for <%=rs("width")%>
slider1.$SetScaleWidth(Math.min(parentWidth, <%=rs("width")%> ));
ASKER
I understand that .. what I am saying is it isn't pulling the data for the size when using slider1.$SetScaleWidth(Mat h.min(pare ntWidth, <%=rs("width")%> )); and the slider stops working.
Does this work?
Is this the sample you are working off of? https://github.com/jssor/slider.js/blob/master/themes-jquery/image-slider.source.html
If I have this wrong, your next step here should be to render your html (run the page so it is working), view source, then paste that code here so we can see how you are using it. Then let us know which parts should be dynamic and how you are getting the data.
slider1.$SetScaleWidth(Math.min(parentWidth, 1040 ));
If it does, check if this worksslider1.$SetScaleWidth(Math.min(parentWidth, <%="1040"%> ));
If that works, see if this works<%
dim myWidth
myWidth="1040"
%>
slider1.$SetScaleWidth(Math.min(parentWidth, <%=myWidth%> ));
If all this works and the below does not, then you need to check that there is data in the rs("width")slider1.$SetScaleWidth(Math.min(parentWidth, <%=rs("width")%> ));
One way you can do this is add the code just before the js you have and write out the width and add a response.end. This will render the page and end it just after it spits out the width. response.write "The width is set to: "& rs("width")
response.end
It is possible the data looks good visually, but may have a character you can't see or space. Try this.if not isnull(rs("width")) then
if isnumeric(rs("width") then
response.write "The width is set to: "& rs("width")
else
response.write "There is data in the width, but it is not numeric"
end if
else
response.write "The field is null"
end if
response.end
Is this the sample you are working off of? https://github.com/jssor/slider.js/blob/master/themes-jquery/image-slider.source.html
function ScaleSlider() {
var parentWidth = jssor_slider1.$Elmt.parentNode.clientWidth;
if (parentWidth)
jssor_slider1.$SetScaleWidth(Math.min(parentWidth, 600));
else
window.setTimeout(ScaleSlider, 30);
}
If it is, why are you trying to set the width dynamically. If you have 10 images listed, they are all going to be the same size or at least in the same size container. Unless for every page refresh (request.querystring or request.form) you are using a different layout that requires the parent to use a different width for the set of images, I think this should be static.If I have this wrong, your next step here should be to render your html (run the page so it is working), view source, then paste that code here so we can see how you are using it. Then let us know which parts should be dynamic and how you are getting the data.
I think rs("width") is not returning the value that you are expecting. Perhaps you have some issue with the code used to retrieve data. Open your page in a web browser, right click and then select View Page Source. In the page source, look at your javascript line and you will see the issue.
I repeat it again that most probably rs("width") is not returning the value that you are expecting.
I repeat it again that most probably rs("width") is not returning the value that you are expecting.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the help
Also you have <%=rs(width")%> and it should be <%=rs("width")%> (missing quote)