How can I put TAB inside itens in selectbox's option itens?
I have:
<select>
<option>Tese - Teste de descrição</option>
<option>Mais um - De desc.</option>
<option>tabulação - Item de tabulação com info</option>
</select>
I wanna:
<select>
<option>Tese Teste de descrição</option>
<option>Mais um De desc.</option>
<option>tabulação Item de tabulação com info</option>
</select>
Update: Ok, vbTab or Chr(9) do it:
<select>
<option>Tese<% Response.Write Chr(9) & Chr(9) & Chr(9) %>Teste de descrição</option>
<option>Mais um<% Response.Write Chr(9) %>De desc.</option>
<option>tabulação<% Response.Write Chr(9) & Chr(9) %>Item de tabulação com info</option>
</select>
but I could only see it in source code. The browser isn't rendering it.
Unfortunately in HTML is not specified a TAB character.
In order to achieve the result you are looking for you can generate the options in the selection box padding with non breaking spaces ( ) the string where you were adding the vbTab. You can try this:
<%
Function Rpad (sValue, sPadchar, iLength)
Dim result=""
For i=0 to i=iLength - Len(sValue)
result = result & sPadchar
Next
Rpad=result
End Function
%>
<select>
<option><% Response.Write Rpad("Tese"," ",10) %>Teste de descriзгo</option>
<option><% Response.Write Rpad("Mais um"," ",10) %>De desc.</option>
<option><% Response.Write Rpad("tabulaзгo"," ",10) %>Item de tabulaзгo com info</option>
</select>
Sorry but I can't try if my code actually works so maybe you have to thweak it a little. I hope you get the sense of it.
Related
I have a combobox with a condition. I would like to bind with the condition, but when I run it, I get the error End of statement expected.
However, when I comment out these line it work perfect.
<li>
<select name="account_type">
<option value="I" <% If Request.Form("account_type") = "I" Then Response.Write("SELECTED") End If %> ">Individual</option>
<option value="C" <% If Request.Form("account_type") = "C" Then Response.Write("SELECTED") End IF %>>Corporate</option>
</select>
</li>
What I am doing wrong with this?
I am using VB.Net Inline coding.
'End If' is only used for multi-line If blocks. If the action is on the same line as the condition then you don't use 'End If'. Also, you ought to count your double quotes because they don;t seem to match.
I'm having a problem here. I've created a page for adding records into a database, it's working fine however the asp script is running every time the page loads, inputting a blank record to the database each time the page is loaded, this is very annoying as it messes with other scripts I have. I feel I am being very stupid but all I need is for the script to run only once the submit button has been clicked, how do I get it to do this?
<!DOCTYPE html>
<html>
<title>
Teacher Registration
</title>
<body>
<h1>
Teacher registration
</h1>
<form name="teacherReg" action="Registration.asp" method="POST">
First name:<input type="text" name="firstname"><br>
Last name:<input type="text" name="lastname"><br>
Password :<input type="password" name="password">
<input type="submit" value="submit">
</form>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Open ="Driver={SQL Server}; Server=QuizDynamics.db.11989315.hostedresource.com; Database=QuizDynamics; Uid=QuizDynamics; Pwd=Compostheap12!;"
set rs=Server.CreateObject("ADODB.recordset")
rs.Open "Select * from teachers", conn
sql="INSERT INTO teachers (firstname, password, lastname)"
sql=sql & " VALUES "
sql=sql & "('" & Request.Form("firstname") & "',"
sql=sql & "'" & Request.Form("password") & "',"
sql=sql & "'" & Request.Form("lastname") & "')"
on error resume next
conn.Execute sql,recaffected
if err<>0 then
Response.Write("No update permissions!")
else
Response.Write("<h3>" & recaffected & " record added</h3>")
end if
conn.close
%>
</body>
</html>
Give your submit input a name attribute - eg submitbutton - then do something like
if request.form("submitbutton") <> "" then
'put your insert code here
End if
I just want to show a result of a variable on a page and i am struggling
heres my code, the variable is in a table as you can see
thanks in advance
<tr><td><%
Dim sTest
sTest = "Monkey"
Response.Write("<p>" & sTest & "</p>")
%>
<p> This is Excel </p>
</td></tr>
Save the below code as HelloWorld.asp. Open this page in a web browser. Tell us what you see.
(Don't put any html code or anything else)
<%
Dim sTest
sTest = "Hello World"
Response.Write(sTest)
Response.End
%>
html code....
<p><%=sTest%></p>
html code....
I tried your code in a .asp file and it seems to be working... What problem are you facing? I have added border=1 to your code to show the table border...
<html> <body>
<%
Dim sTest
sTest= "TEXT"
response.write("<table border='1'><tr><td>")
response.write (sTest)
response.write ("</td></tr></table>")
%>
</body> </html>
I don't understant exactly your code (This is Excel? ,/tr>? ) but:
<%
Dim sTest
sTest= "TEXT"
response.write "<table><tr><td>"
response.write sTest
response.write "</td></tr></table>"
%>
Will write "TEXT" in the only cell of the table.
EDIT: He was using .htm as file extension.
<%
dim req_id
req_id=Request.Form("Req_id")
Set conn=server.CreateObject("adodb.connection")
conn.Open session("Psrconnect")
Set rs=CreateObject("Adodb.Recordset")
rs.Open "select * from releases where project like '%"&req_id&"%'", conn
%>
<SELECT style="LEFT: 454px; WIDTH: 500px; TOP: 413px" name="txtrelease1" id="txtrelease1">
<%
if rs.EOF=true then
%>
<OPTION value="NO Request to Edit">No Request to Edit</OPTION>
<% else
do while rs.EOF<>true
p=InStrRev(rs.Fields(0),"\")
q=Len(rs.Fields(0))
r=(Right(rs.Fields(0),(q-p))) %>
<OPTION value=<%=rs.Fields(0)%>> r </OPTION>
<%
rs.movenext
loop
end if
%>
</SELECT>
i want to right the value of r in the dropdown list. i dont know the syntax. as of now the drop down list shows "r" , not the value inside it. how to do it?
This should do it:
do while not rs.EOF
p=InStrRev(rs.Fields(0),"\")
q=Len(rs.Fields(0))
r=(Right(rs.Fields(0),(q-p)))
%>
<option value="<%=rs.Fields(0)%>"><% =r %></option>
<%
rs.moveNext
loop
I have 2 very simple pages, an HTML page and a classic ASP page .. the html page has a form which calls (and sends) the data to the ASP form (which then prints out the data)
The problem is I'm not getting the value of the radio button, I'm simply just getting "on".
Here is the html:
<form action="form.asp" method="post">
<strong>Gender:</strong>
<input type="radio" value"male" name="gender">Man
<input type="radio" value"female" name="gender">Woman<p></p>
<strong>Size:</strong>
<input type="text" width="20" name="size" size="4"><p></p>
<strong>Color:</strong>
<select size="1" name="color">
<option>blue</option>
<option>green</option>
<option>black</option>
</select><p></p>
<input type="submit" value="Send Order">
</form>
and here is the ASP
<%
Dim strgen, strsize, strcol
strgen = Request.form("gender")
intsize = Request.form("size")
strcol = Request.form("color")
Response.write "Your gender: " & strgen & "<br />"
Response.write "Your size: " & intsize & "<br />"
Response.write "The color you ordered: " & strcol & "<br />"
%>
Like I said, all I'm getting for "strgen" is "on" ...
There's typos in your code, missing equals sign.
value"male"
should be
value="male"
Because the value was ignored it was returning the default value of "on"
Try using an html validator as www.htmlvalidator.com. This site offers a free one which is good (I'm using the professional version myself).
This will find such types immediatly (and will save you countless hours of searching).