Submit button with no name - forms

<input type="submit" value= "OK" />
What I normally do is curl --data "button_name=OK" URL, but the button here has no name. How can I submit via cURL in this case?

CSS Selectors:
Without seeing more HTML you could try a CSS selector of input[value='OK'],
This says, element with input tag having attribute value with value of 'OK'.
CSS query:
VBA:
The CSS selector is applied via the .querySelector method of document.
.document.querySelector("input[value='OK']").Click

In the case that a button doesn't specify a name you will not need to send the button's value in the request, value just exists to provide the button's label in this instance.
I am not very familiar with curl, but give curl --data "" URL a try.

For something like this, without name
<div class="desc"></div>
<div align="center" class="buttons"><input type="submit"
value="Login" /></div>
In VBA, you can use say
dim i as integer
for i = 0 to 19
if webbrowser1.document.getElementsByTagName("input").item(i).getAttribute("type") = "submit" then
if webbrowser1.document.getElementsByTagName("input").item(i).getAttribute("value") = "Login" then
webbrowser1.document.getElementsByTagName("input").item(i).click
Exit For
end if
end if
next
Just Use 19 as an upper bound of the number of input element in the web page and increment it if needed. Once you found which one is it, you can use it straight away

Related

How to pass props to a URL in a form with Vue.js

I'm trying to add a button that will link to a different page made to edit/delete an entry. However, the URL in the action /videos/{the id of the video}/edit
Usually I would just put it in curly braces or use a template literal, but these don't seem to be working. When I try using double curly braces /videos/{{the id of the video}}/edit I get an error saying Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead.
I'm trying to pass props for the id of the video to then apply to the URL, but I'm not sure how to go about that.
I've tried template literals, but it gives me a syntax error when I try using those in action="..." so I tried doing what it tells me to do and use binding :id="this.$props.id" but I'm not sure how to then add the id to the URL without still using interpolation.
<form method="get" :id="this.$props.id" action="/videolist/$id/edit">
<button type="submit">Edit</button>
</form>
props: ['id', 'name', 'description', 'category']
Thanks, I ended up solving it using a template literal. It just didn't work how I thought it did. This ended up working
<form method="get" :action="`/videolist/${this.$props.id}/edit`">
<button class="btn btn-success" type="submit">Edit</button>
</form>

Using InternetExplorer.Application object to check a checkbox on a webpage

I would like to use...
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
With appropriate code to check a checkbox on a webpage
The HTML Code on the rendered page is...
<form class="form-inline" style="float:right">
<div class="checkbox">
<label style="padding-top: 1px">
<input data-bind="checked: orderBook.showAll" style="top:2px"
type="checkbox" /> Show All
</label>
</div>
</form>
I can't use getElementsByID() as I don't think it has one.
Any suggestions?
While your checkbox does not have an ID, it does have a Class. Without seeing more of the HTML code I cannot be entirely sure, but the following code should allow you to set your checkbox to a variable:
Option Explicit
Sub test
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
' Navigate to desired web page
' Code to ensure page is fully loaded
Dim cBox As Object
Set cBox = IE.document.getElementsByClassName("checkbox")(0)
End Sub
Then you can use cBox how you need to (possibly like cBox.Click or another method). Notice that I appended (0) to the end of that statement? That means you are assigning the first instance of that class to the variable. If this checkbox is the only object with the class name of checkbox, then this won't be an issue, but you may have to change this number if it's not.

How to get the filename of a filepicker.io picture to appear in the input field next to it

I am trying to get the filename of an uploaded picture to appear in the input field next to the picker button (for filepicker.io) . Basically I am trying to find what to put in the value field for the input tag to get the filename to appear once the picture is uploaded. Here is the code I have:
<div class="row margin" id='img-row'>
<input id="filename" disabled="disabled" value="<WHAT DO I PUT HERE?>" class="input" type="text" style="width: 360px;"/>
<input name="img" data-fp-class="form-simple-action-btn filepicker_launcher" data-fp-button-text="Choose Image" data-fp-services="COMPUTER,FACEBOOK,FLICKR,INSTAGRAM,PICASA" data-fp-container="modal" data-fp-mimetypes="image/*" type="filepicker" data-fp-apikey="#################" id='campaign-img-input' value="<php echo h($_POST['img'])"/>
</div>
Thank you for your help! I haven't found any other examples like this in the documentation.
The recommended way to do this would be to bind a function to the onchange event of the filepicker input type. Once the upload occurs, the function will be called, and you can pull the filename out of the e.fpfile attribute.
Alternatively, it may be easier to use the filepicker.pick call directly given that you are interested in customizing the behavior. The widget is great for a drop-in solution in many cases, but if you're looking to customize further I'd recommend using the javascript api directly.

how to pass html form data to variable (nodejs / javascript)

so i'm using nodejs and nodejsdb-mysql. i want to make form for adding and searching posts.
I make html page with form, transform it to node using jsdom but how do i set up variables?
for example my html form is like:
name = text input
surname = text input
submit
and how do i pass inserted name/surname to var??
You will need to turn your submit into a button with an event such as onclick - this might be what you are looking for:
<input type="button" value="Submit" id="submit" name="submit" onclick="submit()">
<script type="text/javascript">
function submit(){
var name = document.getElementById('**name**').value;
var surname = document.getElementById('**surname**').value;
alert("Thanks for submitting, " +name);
}
</script>
With nodejsdb-mysql sooner or later you will face real problems like date localization problems and so on, use https://github.com/felixge/node-mysql instead

get checkbox group values

This has driven me really bananas. It's so simple and easy and yet I can't figure out what's wrong with it.
I want to get my checkbox value populated in my controller (for testing purposes).
Here is my form.
<a href='#' name='submitForm'>submit the form</a>
//I have jquery attached to this tag and will submit the form when user clicks it
echo form_open('test/show');
echo form_checkbox('checkbox[]','value1');
echo form_checkbox('checkbox[]','value2');
echo form_checkbox('checkbox[]','value3');
echo form_checkbox('checkbox[]','value4');
echo "<input type='text' name='text1' value='ddd'>";
echo form_close();
//My controller test
public function show(){
$data1=$this->input->post('text1');
//I can get text1 value from input box
$data2=$this->input->post('checkbox');
//it keeps giving me undefined index 'checkbox'
$data3=$_POST['checkbox'];
//same error message
//WTH is going on here!!!!!
}
Please help. This thing drives me nuts! Thanks.
UPDATE:
Thanks for the help. To be more precisely, my submit button is a <a> tag and outside of form tag. It appear that I have to include <a> tag inside my form tag to make them works. Is that true?
A checkbox will not submit any data if it is unchecked as they're not considered successful (as per the w3c specification here)
If you actually tick the box and submit, it'll work - in fact it does, I've just tested it.
You need to wrap calls to $_POST in the isset() function.
if( isset( $_POST['checkbox'] ) ) {}
Calling $this->input->post('checkbox') shouldn't give you an undefined index error as the method deals with this eventuality. the Input::post() method returns false or the value of the checkbox.
Edit --
In response to your amendment to your question, you must use an element of type input with the type attribute set to submit in order to submit your form data without the use of Javascript etc. This button must be INSIDE the <form></form> which you are intending to submit.
<input type="submit" value="Submit">
The type="submit" causes the browser to send the data as submit event occurs. If you wish to use another element insider or outside of the form to do this you need to use Javascript. This however can be disabled on a per browser/user basis and isn't reliable as a result.
// Standard Javascript
<form name="myform"...
<a onclick="javascript:document.myform.submit();" href="javascript:void(0)">Submit</a>
// jQuery
$('#my-a-tag-submit-button').live( 'click', function() {
$('#my-form').submit();
}