request() use id or name attribute classic ASP - html

I have a webpage that I need to fix for ADA compliance. There are a few elements that share ids. The form on the page uses request() to grab information, but it doesn't appear to be the Request object. I'm trying to figure out if this request function? object? uses the name or id attribute. I'm hoping that it's the name attribute.
Here's an example of the ASP code:
if request("submit") = "Submit" then
session("firstName") = request("firstName")
session("middleInitial") = request("middleInitial")
session("lastName") = request("lastName")
end if
Here's the HTML:
<label>First Name: <input type="text" name="firstName" id="firstName" value="<%=session("firstName")%>"></label>
<label>Middle Initial: <input type="text" name="middleInitial" id="middleInitial" value="<%=session("middleInitial")%>"></label>
<label>Last Name: <input type="text" name="lastName" id="lastName" value="<%=session("lastName")%>"></label>

The id is only used client side (primarily for linking, JS, CSS and the for attribute).
The name is used to describe the data that will be encoded in the form submission (so this is what is available to your server side code).

Related

How can I add an attribute to an html element by id value (python flask lxml)

I would like to add a value attribute to multiple input elements. Currently, I am simply using a replace which works but is cumbersome. Is there a way to find an element by its ID attribute and simply add a value attribute?
page = render_template('template.html')
page = page.replace('<input type="text" class="form-control" id="Company" name="Company" placeholder="Company name" data-bs-toggle="tooltip" title="The name of the company that the document is for." onblur="titleCase(this)">',
'<input type="text" class="form-control" id="Company" name="Company" placeholder="Company name" data-bs-toggle="tooltip" title="The name of the company that the document is for." onblur="titleCase(this)" value="' + company + '">')
Is there a way to do this without overcomplicating things?
EDIT: I found this an example in lxml.html documentation that encouraged me to do this:
def fillForm1(page, pDate, company, manager, cAddress, cPhone, cEmail ,sAddress):
form_page = fromstring(page)
form = form_page.forms[0]
form.fields = dict(
pDate=pDate,
Company=company,
Manager=manager,
cAddress=cAddress,
cPhone=cPhone,
cEmail=cEmail,
sAddress=sAddress
)
page = page.replace('<form method="post">', tostring(form, pretty_print=True, encoding='UTF-8', with_tail=False,))
return page
But I keep getting an error about passing a byte back when it should be a string.
Since You are using render_template you can simply use Jinja
Jinja helps you to render your data where ever you want in the html page safely and no need to install anything since the the render_template method already uses it.
You need to specify a something like a placeholder in your html file and then pass a value to it as a keyword to the render_template
you need to put this in your HTML file
<input value="{{company}}" type="text" class="form-control" id="Company" name="Company" placeholder="Company name" data-bs-toggle="tooltip" title="The name of the company that the document is for." onblur="titleCase(this)" >
Now Jinja will search for a keyword (from what you've passed) named company and will substitute its value in place pf {{company}}
to pass the value to Jinja simply use this line in your python code
company_value = "Some Value"
page = render_template('template.html', company=company_value)
Now When Jinja see {{company}} it will replace it with the value passed which is the value of company_value = "Some Value"
Note that you can pass as much values as you want
Jinja has more features that help you to render your data like:
loops
if else statements
and a lot more
Check this Documentation for a quick look Jinja

ng-model binding not updating

I have some models being updated from a look-up. It is the 1st line that's not updating (but the other models are updated correctly). I tried wrapping it in an $apply but that made matters worse:
function mapRequestorToForm() {
//PrimaryCtyhocnOrInnCode binding not updating
//$scope.$apply(function() {
dmpe.form.PrimaryCtyhocnOrInnCode = dmpe.requestor.primaryInnCode;
dmpe.form.hotelName = dmpe.requestor.hotelName;
dmpe.form.requestor = dmpe.requestor;
//});
}
Here's the input element. Funny thing, the pre element is displaying the correct value.
<label for="primaryCtyhocn">Primary Inn Code/ CTYHOCN</label>
<input type="text" id="primaryCtyhocn" name="primaryCtyhocn" ng-model="dmpe.form.PrimaryCtyhocnOrInnCode"
class="form-control required disabled-bg" disabled
placeholder="Primary Inn Code/ Ctyhocn"
ng-minlength="5" ng-maxlength="7" required />
<pre>PrimaryCtyhocnOrInnCode: {{dmpe.form.PrimaryCtyhocnOrInnCode}}</pre>
this one is updated correctly (line 2 of the map method, using the same source object with similar disabled attributes:
<div class="col-md-4">
<label for="hotelName">Hotel Name</label>
<input type="text" id="hotelName" name="hotelName" ng-model="dmpe.form.hotelName"
class="form-control required disabled-bg" disabled
placeholder="Hotel Name required" required />
</div>
In case someone else runs into this and their brain is failing them as mine did. It was an issue with the incoming data, it failed the max length constraint. Thanks to Michael Perrenoud!

Submit form using dynamicallly added fields with the same name in ASP.NET

I have a ASP.net Web page using VB as the language, I have created a form where it asks for 3 different input fields as follows, but the user has the option to add these three fields again for multiple form inputs to make their lives easier and this task faster.
<label>Test Number: <input type="text" id="test_number.1" name="test_number.1" value=""/>
</label>
<label>
Score: <input type="text" name="score.1" id="score.1" placeholder="Required" value="" />
</label>
<label>Comments:<input type="text" name="comments.1" id="comments.1" value="," placeholder="Comments Necessary for future reference" size="70" />
Looking at the submission of the data via firebug this is what it's posting to the serve if you submit only one set of fields.
test_number.1=12555&score.1=75&comments=testing
Looking at the submission of the data via firebug this is what it's posting to the serve if you submit multiple set of fields.
test_number.1=12555&score.1=75&comments=testing&test_number.1=12555&score.1=75&comments=testing&test_number.1=12555&score.1=75&comments=testing
Now I need to insert these values into a database, I know how to do this via PHP utilizing [] and then dealing with it on the backend. But I'm still learning asp.net and seem to be having some major issues on how to get this to work. If anyone can help that would be great.
Solution can be:
1st set of controls:
<input type="text" name="testnumber" />
<input type="text" name="testscore" />
<input type="text" name="testcomments" />
add next set
<input type="text" name="testnumber" />
<input type="text" name="testscore" />
<input type="text" name="testcomments" />
and so one.
On server side:
var testnumbers = Request["testnumbers"];// comma seperated values
var testscores = Request["testnumbers"];// comma seperated values
var testcomments = Request["testcomments"]; // comma seperted values.
split all values by comma. you will get array of values for each
string[] testnoList = testnumbers.split(',');
string[] testscoresList = testscores .split(',');
string[] testcommentsList = testcomments .split(',');
for(int i=0; i<testnoList.Lenght; i++)
{
var testno = testnoList[i];
var score = testscoresList[i];
var comments = testcommentsList[i];
// do whatever you want here
}

Struts2 / css in textfield

I am beginning with struts2 programming and I wondered how I could do the following thing. I have this struts code in a form :
<s:textfield name="aName"/>
And I had this html code before using struts2 :
<input id="aLogin" type="text" class="form-control" name="username" value="" placeholder="something" required autofocus>
How could I "merge" these two lines to do the same html code but using my struts2 code ?
In Struts tags, class ans style becomes cssClass and cssStyle; in old versions of Struts, required was an attribute indicating when to put the * mark, now changed to requiredLabel to avoid overriding the HTML5 required attribute. Other HTML5 attributes like placeholder and autofocus can be set because Textfield tag Allows Dynamic Attributes.
Then in your case:
<s:textfield id = "aLogin"
name = "aName"
cssClass = "form-control"
value = ""
placeholder = "something"
required
autofocus />
For other info, refer to the official <s:textfield/> documentation
name should be same as that of bean variable,therefore,
<s:textfield name="username"/>
this will work, only if you have setUsername method in your action class.

Passing content to a URL (Who.is)

I am going to need to add a form to a page on a site, that takes a domain name as the input from the viewer and sends it to who.is so that the DNS for this domains a returned.
When searching onwho.is, the URL for the search query when looking for me.com looks like this:
http://who.is/dns/me.com
I am struggling here since I can't pass the domain name using the variable form, with ?q=...
Any Ideas?
This is so far the html I have for this form:
<form method="get" action="http://who.is/dns/" target="_blank">
<input type="text" name="q" size="31" maxlength="255" placeholder="Who is" width="255"/>
</form>
Thanks
You will not be able to do this in HTML unless you find a URL with parameters, like TechnoKnol posted.
You need this or a server process
window.onload=function() {
document.getElementById("who").onsubmit=function() {
window.open("http://who.is/dns/"+document.getElementById("q").value(),"_blank");
return false;
}
}
using
<form id="who">
<input type="text" id="q" size="31" maxlength="255" placeholder="Who is" width="255"/>
</form>
By inspecting on who.is, I found below url
http://who.is/search.php?search_type=Whois&query=me.com&commit=Search
With some modification in your form will work.