How to get absolute URL in form action attr using MSHTML getAttribute method? - mshtml

Here's the deal I have HTML code like this
<form action="/test.php">
First name: <input type="text" name="firstname" /><br />
Last name: <input type="text" name="lastname" />
</form>
I would like get full url like http://localhost/test.php calling getAttribute ( http://msdn.microsoft.com/en-us/library/aa752280(v=vs.85).aspx )
I'm trying to do it with the following code (Delphi)
formAction := form.getAttribute('action', 4);
but it only shows '/test.php'. How to make it work?
// Sorry for my bad english

You get obtain the current URL from iwebbrowser2
Do a string operation and get the complete URL.
Hope it helps.

Related

What is the best locator for the below tag?

Below is the tag for a password field in Login form.
Our guys used the same class name for EMail field also. Hence I cannot use className for password to locate it in protractor, since xpath and css(id design changes) are not reliable, what is the best option for me?
Tag for Email field:
<input class="native-input sc-ion-input-md" aria-labelledby="ion-input-0-lbl" autocapitalize="off" autocomplete="off" autocorrect="off" name="ion-input-0" placeholder="" required="" type="email">
Tag for password field:
<input class="native-input sc-ion-input-md" aria-labelledby="ion-input-5-lbl" autocapitalize="off" autocomplete="off" autocorrect="off" name="ion-input-5" placeholder="" required="" type="password">
For submit button:
<ion-button _ngcontent-rbh-c129="" type="submit" color="loginbutton ion-margin" class="ion-color ion-color-loginbutton ion-margin md button button-solid ion-activatable ion-focusable hydrated">Login</ion-button>
I don’t suggest you to go with ion-input properties since it’s Ionic related properties generated during the build process and it can be dynamic.
Use type instead since it is:
Obvious
Static
input[type="email"]
And
input[type="password"]
After some time you will have hard time understanding your own code and trying to recall what ion-input-0
refers to.
By css:
element(By.css('input[name="ion-input-0"][type="email"]')),
and:
element(By.css('input[name="ion-input-5"][type="password"]')),

Why url is set in $_GET when i use post method

have you guys any ideas why the url is set in the $_GET, when i submit a form with post method?
I have a form like this:
<form action="/test/show/" method="post" enctype="multipart/form-data">
<input name="product" value="testing">
<input type="file" name="image">
<input type="submit" value="go" name="submit">
</form>
In my chrome i can see it will be send as post, but if i do this:
if (count($_GET) > 0) {
var_dump($_GET);
}
I get this result:
array(1) { ["url"]=> string(10) "test/show/" }
and i have no idea why?
Can you help me?
Under normal circumstances, with that URL, it wouldn't be. Presumably you are using mod_rewrite or similar to map /test/show onto something like /index.php?url="%2Ftest%2Fshow.
This is because PHP picked poor names for the $_GET superglobals.
An HTML form with method="GET" will put the data from its form controls in the query string, but that isn't the only way to request a URL with a query string.
$_GET contains data from the query string irrespective of the request method.

How to create a form that uses "=" instead of "&" with HTTP GET?

We have a form:
<form name=input action=https://www.foo.com method=get>
<input type=hidden name=foobar>
<input type=hidden name=ticket>
<input type=text value=bar>
<input type=submit value=IN>
</form>
then in the end we will get:
foobar=&ticket=
but we need
foobar=ticket=
...what is the syntax for creating an HTML form that will put "=" instead of "&" in given places?
Replace
<input type=hidden name=foobar>
<input type=hidden name=ticket>
with
<input type="hidden" name="foobar" value="ticket"/>
The bit after the = is the parameter's value, so this is saying "submit a parameter called foobar with the value ticket."
The & comes from the "application/x-www-form-urlencoded" enctype of the form, which is the default. The other options available are described in the HTML standard, but the short story is that the encoding you want is not possible with a standard HTML form.
If Javascript is an option, you could try overriding the submission process and read the form values, building your own string according to your requirements, and direct the browser to the resulting URL.
I have a feeling this problem would be better solved by making the server at the "action" URL take the parameters in the standard & way, though...

How can I conditionally require form inputs with AngularJS?

Suppose we're building an address book application (contrived example) with AngularJS.
We have a form for contacts that has inputs for email and phone number, and we want to require one or the other, but not both: We only want the email input to be required if the phone input is empty or invalid, and vice versa.
Angular has a required directive, but it's not clear from the documentation how to use it in this case. So how can we conditionally require a form field? Write a custom directive?
There's no need to write a custom directive. Angular's documentation is good but not complete. In fact, there is a directive called ngRequired, that takes an Angular expression.
<input type='email'
name='email'
ng-model='contact.email'
placeholder='your#email.com'
ng-required='!contact.phone' />
<input type='text'
ng-model='contact.phone'
placeholder='(xxx) xxx-xxxx'
ng-required='!contact.email' />
Here's a more complete example: http://jsfiddle.net/uptnx/1/
if you want put a input required if other is written:
<input type='text'
name='name'
ng-model='person.name'/>
<input type='text'
ng-model='person.lastname'
ng-required='person.name' />
Regards.
For Angular2
<input type='email'
[(ngModel)]='contact.email'
[required]='!contact.phone' >
Simple you can use angular validation like :
<input type='text'
name='name'
ng-model='person.name'
ng-required='!person.lastname'/>
<input type='text'
name='lastname'
ng-model='person.lastname'
ng-required='!person.name' />
You can now fill the value in only one text field. Either you can fill name or lastname. In this way you can use conditional required fill in AngularJs.
In AngularJS (version 1.x), there is a build-in directive ngRequired
<input type='email'
name='email'
ng-model='user.email'
placeholder='your#email.com'
ng-required='!user.phone' />
<input type='text'
ng-model='user.phone'
placeholder='(xxx) xxx-xxxx'
ng-required='!user.email' />
In Angular2 or above
<input type='email'
name='email'
[(ngModel)]='user.email'
placeholder='your#email.com'
[required]='!user.phone' />
<input type='text'
[(ngModel)]='user.phone'
placeholder='(xxx) xxx-xxxx'
[required]='!user.email' />
For Angular 2
<input [(ngModel)]='email' [required]='!phone' />
<input [(ngModel)]='phone' [required]='!email' />

ASP.NET MVC 2 Input ID

Adding the following to my view:
<input type="text" runat="server" id="newBookingRef" name="newBookingRef" />
Results in the following HTML:
<input type="text" id="MainContent_newBookingRef" name="ctl00$MainContent$newBookingRef">
If I use the helper method Html.Textbox, the ID is generated as I would expect "newBookingRef".
How can I stop it prefixing the ID on standard input controls with the content placeholder id? I tried playing with the ClientIdMode of the content placeholder but this didn't seem to help.
Thanks,
Ben
Remove the runat="server" attribute.