How do I start an element hidden but then show it when I select it from dropdown, HTA? - hta

A few questions in one post. I am making an HTA script that has a dropdown for a few examples but then has a 'custom' option. When I click custom I would like for a text box and some words telling the user to enter a number in miliseconds to show under it and then hide if I choose another option.
My questions:
1. How do I start the textbox and the words above it hidden?
2. How do I make it appear/ disappear based on the users choice in the
dropdown?
I will post the relevant code that I have as of now that I tried but does not work. Please note this is my first time messing with hta so some things might be redundant or i might be missing some parts as i just pulled the relevant parts from my script. Also right now the text box and words are not hidden on start as i don't know how to do that.
<BODY>
<SCRIPT LANGUAGE="VBScript">
Set wshShell = CreateObject("WScript.Shell")
Sub btn01_OnClick
Dim strProduct
Dim Timerdelay
oElements = Window.Message.SelectedIndex
strProduct = Window.Message.Options(oElements).Text
Select Case strProduct
Case "1 Second"
Timerdelay=1000
CustomTime.style.visibility="hidden"
ShowTime.style.visibility="hidden"
Case "3 Seconds"
Timerdelay=3000
CustomTime.style.visibility="hidden"
ShowTime.style.visibility="hidden"
Case "5 Seconds"
Timerdelay=5000
CustomTime.style.visibility="hidden"
ShowTime.style.visibility="hidden"
Case "30 Seconds"
Timerdelay=30000
CustomTime.style.visibility="hidden"
ShowTime.style.visibility="hidden"
Case "0.5 Seconds"
Timerdelay=500
CustomTime.style.visibility="hidden"
ShowTime.style.visibility="hidden"
Case "Custom"
CustomTime.style.visibility="visable"
ShowTime.style.visibility="visable"
Timerdelay= CustomTime.Value
End Select
End Sub
</SCRIPT>
<span id=ShowTime><P>Enter Your Time Delay In Miliseconds<P>
<input type="text" name="CustomTime" size="30"></span>
<Input Type = "Button" Name = "btn01" VALUE = "START">
</BODY>

You can use the atribute onchange='myfunctionName(possible_value)' on the dropdown.
On the linked function, check the value of the dropdown and your switch case should work. Also, check for syntax error such as "visable" instead of "visible".
If you don't know how to retrieve the value from the dropdown, you can refert to this link: Get drop down value

Related

plone.app.event- Using IEventBasic as a behavior, how can I properly set the end field programatically in an event?

I have a dexterity content type (my.product.myobject) that uses the IEventBasic behavior (implemented in the xml file with other behaviors) and I'm trying to make the end field be set within the same week of the start field. I attempt to correct the end date in an IObjectAddedEvent (zope.lifecycleevent.interfaces.IObjectAddedEvent).
I first get the week range from the start field:
def getWeekRangeFromDate(a_date,offset=1):
start = (a_date - timedelta(days=(a_date.weekday() + offset) % 7)).replace(hour=0,minute=0)
end = (start + timedelta(days=6)).replace(hour=23,minute=59)
return {'start':start,
'end':end,
}
def myObjectAdded(myObject, event):
week_range = getWeekRangeFromDate(myObject.start)
if myObject.end > week_range['end']:
myObject.end = week_range['end']
I have the end field printed in the browserview and I use IEventAccessor to extract the end date from the myObject:
class View(BrowserView):
def __init__(self,context,request):
...
self.context = self.context
def getFormattedEnd(self):
if self.context.whole_day == False:
return IEventAccessor(self.context).end.strftime('%m/%d %I:%M %p')
...
When it doesn't need to be programmatically corrected, the end field displays correctly, but when it does, it appears 5 hours off.
In my myObjectAdded event, I tried:
if myObject.end > week_range['end']:
myObject.end = week_range['end'] - timedelta(hours = IEventAccessor(myObject).end.offset().total_seconds()/3600)
This does appear right actually, but when I go to the edit form and change the start field, the end field ends up changing itself seemingly random. Changing the starting hour field to 16 changed the end's month about two weeks ahead.
How can I set it without it acting up? Am I misundertanding how to use IEventBasic?
Edit: I'm coming across something really interesting. In the edit form, the Start End Validator is failing.
Event Starts - 25/November/2016 9:00
Event Ends - 25/Novermber/2016 20:00
I click submit and the status message says End date must be after the start date.
Edit: The version of Plone I am using is 4.3.

Second Dynamic DIV over writes first dynamic DIV

I have searched for almost three days now and I can't find an answer to this question. As I am somewhat new to ASP.Net I am not sure what the problem is.
Here is the situation. I have an aspx page that has a web form on it. When this form loads it has two SQL queries that execute and populate different controls.
My problem lies not with the queries but creating dynamic DIV tags and adding controls to them. If the query returns one or no records everything is fine. but if there are 2 or more records returned I only end up with the last record being displayed.
When I view the page source (from the browser) I can see the DIV tag ID that was created last, but the first DIV tag is gone. It is like the first DIV tag gets over written or something. I have no idea as to why or what is causing this.
Can anyone help please?
Here is my code:
While (incCounter <= rowCount)
DivName.ID = ("rev" & Convert.ToString(incCounter)) 'Create Div name of rev and the current counter number ex. rev1
review_comments.Controls.Add(DivName) 'Add DIV to web form
rName = (rName & Convert.ToString(incCounter)) 'Create name control name
rDate = (rDate & Convert.ToString(incCounter)) 'Create date control name
rComments = (rComments & Convert.ToString(incCounter)) 'Create comment control name
DivName.Controls.Add(New LiteralControl("<br />"))
DivName.Controls.Add(rRevByLabel)
rNameTextBox.ID = rName
DivName.Controls.Add(rNameTextBox)
DivName.Controls.Add(nbSpace)
DivName.Controls.Add(nbSpace)
DivName.Controls.Add(nbSpace)
DivName.Controls.Add(nbSpace)
DivName.Controls.Add(nbSpace)
DivName.Controls.Add(nbSpace)
DivName.Controls.Add(nbSpace)
DivName.Controls.Add(rDateLabel)
DivName.Controls.Add(rDateTextBox)
DivName.Controls.Add(New LiteralControl("<br />"))
DivName.Controls.Add(rCommentLabel)
DivName.Controls.Add(rCommentsTextBox)
'Assign data from query to new textboxes
rNameTextBox.Text = dtR.Rows(incCounter - 1)("reviewed_by_name").ToString()
rDateTextBox.Text = dtR.Rows(incCounter - 1)("reviewed_by_date").Date()
rCommentsTextBox.Text = dtR.Rows(incCounter - 1)("review_comments").ToString()
rName = "revName"
rDate = "rDate"
rComments = "revComments"
incCounter += 1
End While
I know all the variables are set up correctly because it shows me the last record.
What stupid thing am I doing?

ASP, Forms and passing variables between frames

I am pretty new to ASP, I know VBScript reasonably well though. What I am trying to do is create a website with 2 frames. In the top frame, it asks for a year (from a selection box) and a week number (from a selection box). It should then display the dates relating to the selection and a button to process the request. When the button is clicked the bottom form then processes a SQL query based on the selection in the top frame and displays the info.
Now, my problem is when it comes to understanding ASP. With ASP, all the code is processed then the output is sent to the browser. How do you update variables or even pass them to other frames when the code has already processed?
I just need some pointers on the way forward to accomplishing the above.
Thanks
First off, don't use frames: they're annoying, ugly, and outmoded.
You can do something like this in asp, but it's going to require a round trip (or two) to the server.
The basic outline of the page (let's call it thispage.asp) would be something like
<html><head>[head stuff]
<%
dim yr, wk, i
yr = request.form("Year")
wk = request.form("Week")
'- if you use form method='get', then use request.querystring("Year")
if not isnumeric(yr) then
yr = Year(date) 'or whatever else you want to use as a default
else
yr = CInt(yr)
end if
'similar validation for wk
%>
</head>
<body>
<form method="post" action="thispage.asp">
<select name="Year" size="1">
<%
for i = Year(Date) - 2 to Year(Date) + 2
response.write "<option value='" & i & "'"
if i = yr then response.write " selected"
response.write ">" & i & "</option>"
next
%>
</select> [similar code for week or date or whatever]
<input type="submit">
</form>
<%
If yr <> "" and wk <> "" Then
'- look up stuff in database and output the desired data
'- (this part will be much longer than this)
Else
Response.Write "<p>Please make your selections above.</p>"
End If
%>
</body></html>
If you need to output form fields that are dependent on the user's initial year & week selections, then you're going to need more than one trip to the server, but it's still the same idea: set up the variables you're going to need, see if they have values, write out the form, and then if all the necessary variables have all the necessary values, then you can do your output stuff.

how to implement a check box in classic asp

I have a checkbox
<td><strong>Online Ordering: </strong></td>
<td><input type="checkbox" name="OnlineOrdering" value="<%=OnlineOrdering%>" <% if OnlineOrdering = True then response.write "checked='Checked'" end if %>/></td>
How do i capture whether the checkbox is checked or unchecked when form is submitted?
OnlineOrdering = request.form("OnlineOrdering")
this does not work?
This should assign a true/false to the variable OnlineOrdering:
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
OnlineOrdering = (Request.Form("OnlineOrdering") <> "")
End If
I found this post because I was trying to solve the same problem. I have a solution that seems to work well.
In the HTML form, create dynamically generated checkboxes. The value of this_box_id used below can be any unique number. In my case it was the primary key (autonumber) for that question from the SQL Database . Dynamically generated the check boxes with an associated hidden field:
<input type="hidden" name="check_box_indicator" value="<%=this_box_id%>">
<input type="checkbox" name="box_id<%=this_email_selection_id%>"
value="<%=this_box_id%>">
When asp returns the values for this, it will return multiple values for check_box_indicator. Here's a sample query string snippet:
...&check_box_indicator=78&box_id78=78&check_box_indicator=98&check_box...
On the next page, ASP will read through the form data. It will find EVERY check_box_indicator and it's value. That value can be used to check the value of the associated checkbox. If that checkbox comes back, it was checked, if it doesn't you will know that it wasn't checked. In the sample above, checkbox 78 was checked and so the box_id78 value was passed, while checkbox 98 was not and box_id98 was not sent. Here's the code to use this.
For Each this_box_id In Request.Form("check_box_indicator") 'check EVERY box'
box_state = Request.Form("box_id"&this_box_id) 'collect passed values only'
if box_state > 0 then
store_value = "y"
else
store_value = "n"
end if
' you now have the this_box_id number identifying this item in the DB, '
' the value of the check box, if it was passed '
' and a definite y or n value '
Next
With the example querystring, you will get 78 y, 98 n

Can't set value of hidden input to comma seperated list in ASP VB.net

Hi I've run into a really annoying problem, I'm trying to set the value of a hidden input to a comma seperated list taken from a database but in pure CSV format it won't set the value.
The input tag and ul tag looks like this (I am aware of asp:hiddenfield and it's value property but I'm not using it as I still have this issue):
<ul id="keywords" runat="server">
</ul>
<input type="hidden" id="keywordsBox" runat="server" />
The code I'm using to populate it is:
'connection strings and all that stuff is set up and using a SqlDataReader to sort through results
while result.Read()
keywordsBox.Attribute.Add("value", result.Item("keywords"))
keywords.innerHTML = "<li>" & Replace(result.Item("keywords"),",","</li><li>") & "</li>"
End while
This will populate the li tags but will not populate the value for the input, I've tried using the replace function on the list for the value but it only works if I remove the commas or put other characters infront of them. I've also tried replacing it with the HTML code for a comma but just prints the HTML code out.
Has anybody else ran into this at all? How'd you fix it?
Try the below code, this will solve your problem:
dim hValue as string =""
while result.Read()
hValue += result.Item("keywords")
keywords.innerHTML = "<li>" & Replace(result.Item("keywords"),",","</li><li>") & "</li>"
End while
keywordsBox.Attribute.Add("value", hValue )

Resources