How to get Index of the FORM Element in the WebBrowser Control? - vb.net

let say a site has 2 forms: one search form and the other is a registration form...
<form>
Search: <input type="text" name="s">
<input type="hidden" name="a" value="search">
<input type="submit" value="Search">
</form>
[..]website content blabla[...]
<h2>Registration</h2>
<form>
E-Mail: <input type="text" name="email">
<input type="hidden" name="a" value="reg">
<input type="submit" value="Register">
</form>
If I submit a form, I want to know to which form the clicked submit button belongs. GetElementbyId is not possible because the id is not always available. I want to get the index. Any ideas? (WebBrowser Element in VB.NET or C#)

You cant refer to Form object of Input Element e.g btn.Form.Name should work; give it a try
http://msdn.microsoft.com/en-us/library/aa703812(v=vs.85).aspx (reference to IHTMLInputElement::form Property)

Related

Clear all input fields on submit using Hyperscript

I'm playing around with htmx and hyperscript, and I want all input fields in the form below to be cleared on submit:
<form hx-post="/example" hx-target="#table tbody" hx-swap="beforeend"
_="<what should I write here??>">
<label class="control-label" for="firstNameInput">First Name</label>
<input id="firstNameInput" name="firstName" class="form-control" type="text" required placeholder="John"/>
<label class="control-label" for="lastNameInput">Last Name</label>
<input id="lastNameInput" name="lastName" class="form-control" type="text" required placeholder="Doe"/>
<button class="btn btn-primary">Add User</button>
</div>
</form>
I've tried replacing <what should I write here??> with e.g. on submit put '' into <input/> and on submit put '' into <input[value]/> and lots of other combinations but I fail to get this work.
Q: How can I clear all input fields when the form is submitted?
Try with on htmx:afterRequest reset() me

How to stay on the same page after a form submission integrated to a Google form

In my website i have a contact form, and i've integrated it with a Google form. I've added the google form's execute URL as the action URL so once its submitted the form is being populated with the form data. the way i have done it
But when its being submitted, its redirecting to a google form's response page. What i need is once its submitted, to stay on the same page and give an alert. Im not sure how to do this in vue js. Any suggestion will be appreciated.
the content on the redirected page
{"result":"success","data":"{\"name\":[\"sdvsdv\"],\"company\":[\"dsvdv\"]}"}
Form in vue js view
<form method="POST" id="appointment-form" action="https://script.google.com/macros/s/AKfycbzRHvjfmIZdwKnOm26PeFv64OyyyGAfcr68MxvYw/exec">
<div class="form-group">
<input type="text" placeholder="Your name" name="name" class="form-control" id="name" required>
</div>
<div class="form-group">
<input type="text" placeholder="Company name" name="company" class="form-control" id="company" required>
</div>
<buttontype="submit" class="btn btn-default btn-block form-submit-btn">Submit</button>
</form>
After read your code properly, i found many errors.
How are you saving input values?
To save, you have to use ```v-model directive````
I guess you save the input values in somewhere. To avoid your problem, you can add a method and call it on submit, and inside the method save your input values.

Validations not working in ODOO website

I have created a template and a controller for it in ODOO v8. Following is the template:
<template id="myTemplate">
<t t-call="myTemplateHeader"/>
<div class="myClass">
<form action="/myControllerAction" name="myTemplateForm">
<input type="text" id="name" name="name"/>
<input type="text" id="lname" name="lname"/>
<input type="text" id="email" name="email"/>
<input type="submit" value="Submit"/>
</form>
</div>
</template>
And I have written a controller for the action /myControllerAction.
#http.route(['/myControllerAction'], type='http', auth="public", website=True)
def index(self, **post):
data = {}
# some action here
# to submit and fetch values
request.website.render("my_module.mySecondTemplate", data)
I have added validations on the fields in the form so that one cannot submit the form without entering the values in all the text fields given. The validations in JS works, it shows an alert message when the text fields are blank(one alert for each text field). But, after clicking the OK for the alert message of email field, it submits the form even when the field is empty. I have checked the issue and found that the problem exists only if I provide
<input type="submit" value="Submit"/>
and it will be solved if I am using
<input type="button" value="Submit"/>
But I have to make some calculations in the controller and need to retrieve some data from the database to show on the next page. For this, type="button" cannot be used as it just submit the form and redirect to next page without making a call to the controller function. type="submit" will make the call to the controller, but validations are not working as described earlier. Also submitting the form using onclick event of the button in javascript won't call the controller. I want validations on the form and then call the controller(on submit). Is there any way I could implement this in ODOO v8?
For making fields mandatory in ODOO templates, the attribute required="required" can be used on input fields.
<input type="text" id="name" name="name" required="required"/>

Not able to extract the name of the radio button from DOM using the xpath using selenium

When i pass //input[#type='radio'] in the xpath, i'm able to select all the radio buttons in the list but i am not able to select a particular radio button by it's name.
Name of the radio button is the fourth term in quotes inside the render_selected_term list.
<input type="radio" onclick="Element.show('indicator_radio_term_190');render_selected_term('190','1','275464','AQCB Number')" value="190" name="radio_190"/>
<input type="radio" onclick="Element.show('indicator_radio_term_179');render_selected_term('179','1','275464','AQCB Number (iLink)')" value="179" name="radio_179"/>
<input type="radio" onclick="Element.show('indicator_radio_term_19');render_selected_term('19','1','275464','Acceptance')" value="19" name="radio_19"/>
<input type="radio" onclick="Element.show('indicator_radio_term_148');render_selected_term('148','1','275464','Account (iLink)')" value="148" name="radio_148"/>
<input type="radio" onclick="Element.show('indicator_radio_term_206');render_selected_term('206','1','275464','Additional Non-standard Terms')" value="206" name="radio_206"/>
<input type="radio" onclick="Element.show('indicator_radio_term_220');render_selected_term('220','1','275464','Assigned Contract Manager (iLink)')" value="220" name="radio_220"/>
<input type="radio" onclick="Element.show('indicator_radio_term_12');render_selected_term('12','1','275464','Assignment')" value="12" name="radio_12"/>
<input type="radio" onclick="Element.show('indicator_radio_term_188');render_selected_term('188','1','275464','Authorized Purchasing Entity(ies)')" value="188" name="radio_188"/>
<input type="radio" onclick="Element.show('indicator_radio_term_226');render_selected_term('226','1','275464','Award (iLink)')" value="226" name="radio_226"/>
<input type="radio" onclick="Element.show('indicator_radio_term_196');render_selected_term('196','1','275464','Award Amount')" value="196" name="radio_196"/>
I would suggest you to use css selector in this case and attribute search. Be very careful when you use the following selector. The match you are looking for has to be unique.
Note: I am not sure which match you are looking for. So, I am showing you an example.
[onclick*='148']
Should match <input type="radio" name="radio_148" value="148" onclick="Element.show('indicator_radio_term_148');render_selected_term('148','1','275464','Account (iLink)')"/>
Try this:
<div id="something">
<input type="radio" onclick="Element.show('indicator_radio_term_190');render_selected_term('190','1','275464','AQCB Number')" value="190" name="radio_190"/>
<input type="radio" onclick="Element.show('indicator_radio_term_179');render_selected_term('179','1','275464','AQCB Number (iLink)')" value="179" name="radio_179"/>
IList<IWebElement> inputs = browser.FindElements(By.XPath("//div[#id='something']/input)");
foreach(var element in inputs)
{
if(element.getAttribute("name").Equals("radio_12"))
element.Click();
}

text fade on input field, where is this being configured

i have this website im building, my client is using a template and the template has contact forms, now i cant seem to understand how to get the text fade on click for input fields to work on any additional fields i make on top of what was there on the template.
http://daniloportal.com/NPC2/contact.html
on that page take a look at the form, the values with *'s disappear but the clone EMAIL input i made doesnt cause i took the * off the value.
Ive been going crazy trying to figure out where this is being configured on the page, If any inspect elementors can take a look and let me know i would greatly appreciate it!
this is the code snip
<form id="ajax-contact-form" action="">
<input type="text" name="name" value="Name *" title="Name *" />
<input type="text" name="email" value="Email *" title="Email *" />
<input type="text" name="email" value="Email " title="Email *" />
<textarea name="message" id="message" title="Message *">Message *</textarea>
<div class="clear"></div>
<input type="reset" class="btn btn_clear" value="Clear form" />
<input type="submit" class="btn btn_blue btn_send" value="Send message!" />
<div class="clear"></div>
</form>
Search your code to find what makes the input's value disappear. E.g., look for behavior that clears the value of form fields (either element.value = '' if using plain javascript, or element.val('') if using jquery).
Then you can see what is the condition to clearing it. In your case, seems that the condition is that the input's value is equal to it's "title" attribute (you can edit both using "Inspect Element" in Chrome).