Using URL parameters for webforms that seem to be resistant to them? - url

I'm attempting to write a little script that, as part of it, would automatically complete a webform using data from a dictionary.
I've developed this script for other forms in the past with a pretty simple setup: the elements in the form are identified with a line like...
<input type="text" name="full_name" id="full_name_id" maxlength="80" value="">
<input type="text" name="title" id="title_id" maxlength="80" value="">
So, I'd navigate to www.theformsite.com/theform.php?full_name_id=David&title_id=Stuff and find those slots already filled in.
For a couple new forms I've been working with though, that doesn't seem to work: there's no response to these parameters. Are there any general things that could prevent this from working that I should check on?

Related

Angular2 - how to restrict copy/paste in an input field to a limited charaters?

Iam a newbie to frontend. can anyone help me out on how to restrict the input field to take limited character while copy/pasting? I tried doing this way, it works when you type, but breaks when you copy/paste?
<input type="text" disabled="{{isDisabled}}" placeholder="Search" maxlength="50" [(ngModel)]="searchText" (keyup)="updateTable()" />

Ruby - Set of inputs to array

I'm trying to have a dynamic set of inputs in a form, that start with just one, where you can add or remove them with add/delete buttons. Then upon submission of a form, it turns the values of the inputs into a hash then that hash into a string for storing. I really have no idea where to start. So any tips will be helpful.
If using javascript would help, I can go that route, but i'm not sure how to make the javascript and ruby talk.
Depending on your use-case, there are a few options you might want to use. Since you've tagged this with rails, I'm assuming you have access to JQuery. Here's one (very simple) example of how you might go about adding fields to the page dynamically using it:
https://jsfiddle.net/3Lyvw0jm/
If you plan on storing these fields in one of your models, you may want to take a look at implementing nested attributes.
As pretty much a common web thing (not Rails-specific), you would make the name value look like some_name[].
So instead of having multiple inputs with different names like this:
<input type='text' id='my_input_1' name='my_input_1' value='string_1' />
<input type='text' id='my_input_2' name='my_input_2' value='string_2' />
<input type='text' id='my_input_3' name='my_input_3' value='string_3' />
...where on the server you get:
params :my_input_1 # 'string_1'
params :my_input_2 # 'string_2'
params :my_input_3 # 'string_3'
You would have:
<input type='text' id='my_input_1' name='my_inputs[]' value='string_1' />
<input type='text' id='my_input_2' name='my_inputs[]' value='string_2' />
<input type='text' id='my_input_3' name='my_inputs[]' value='string_3' />
...where on the server you get:
params :my_inputs # ['string_1','string_2',string_3']

Rails-Backbone Model save issue

This page is to edit the account information.
Template file,
<input type="text" id="account_name" class="form-control" placeholder="Enter Name" value="<%=account.name%>"/>
<input type="text" id="account_company_name" class="form-control" placeholder="Enter Company Name" value="<%=account.company_name%>"/>
<a id="account_next_btn" class="btn" role="button">Next</a>
view file,
events:
'click #account_next_btn': "updateAccount"
updateAccount: (e)->
e.preventDefault()
#account.save({"name": #$el.find("#account_name").val(),"company_name": #$el.find("#account_company_name").val()})
ok, this works fine. it sends the updated input form parameters.
the thing i'm curious is, there should be a better way, not setting the updated values manually like my code.
in rails backbone:scaffold it doesn't have this kind of code.
it just
#model.save()
that is all they do.
but in my code, if i just call
#account.save()
it sends the parameter, that not have been updated.
That’s because Backbone by default doesn’t include any kind of data binding library. Data binding lets you keep a model attribute synced with a form field value.
Backbone-Rails includes the simple backbone_datalink.js, which sets up a simple form binding when you create the scaffold.
There are many other binding plugins that work with Backbone, such as Backbone.ModelBinder and Rivets.js.

Display existing individual data in placeholder

Im using HTML 5 placeholder and i was wondering if it would be possible that the placeholder display the existing current data (extracted from database).
<input type="text" name="email" id="current_email" placeholder="HERE I WOULD LIKE THE USER's CURRENT EMAIL TO BE DISPLAYED"value="" />
Is there any easy way to do this ? (i'm quite new to html5 / php / js / jquery)
Thank you for your time.
Replace your placeholder with
placeholder="<?php echo $user['mail']; ?>"
By the way, $user['mail'] in an exemple, replace it with whatever your variable is.
This is some very basic use of HTML / PhP, before asking more questions like this, you should give a look at some tutorials, it will be quicker
Did you try to do something like this ?
<input type="text" name="email" id="current_email" placeholder="<?=$var?>"value="" />
It works for me in javascript at least.

Rails will_paginate custom renderer manual page number

Hy
What i want to do is to create a custom renderer for will_paginate which renders first, previous, next and last page and a input field where the user can type in the page number manually. I already have the links for first, last etc. but i stuck at the input field. I could create a form in the view but the input field has to be rendered between the previous and next links.
Does anyone know how to do this?
Thanks for your help
You can do this as a separate form (make sure it is a GET). All you
need is the one input element named page. Something as simple as this
should work (not all browsers may like the #). I dropped it into a
site I'm playing with now and it worked. Put it anywhere on your page.
You might have to make something more complicated if you need to
incorporate search terms.
<form action="#" method="get">
Go to page: <input type="text" name="page" value="" size="2"
maxlength="4" />
<input type="submit" name="btnSubmit" />
</form>

Resources