Display existing individual data in placeholder - 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.

Related

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

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?

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 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>

Can i use html tags in struts2 form?

Can i use html form tags in struts 2 form?
Like
<input type='text' value='' />
<input type='submit' />
Will the values be posted through struts2?
It's not at all mandatory to use struts2 tags. You could go with regular HTML.
Of course.
This is one of those questions you can just try.
All the S2 form tags do is emit HTML, filling in various attributes as required. (It's slightly more complicated than that, but ultimately, they spit out an HTML form field.)
Flip your question on its head: why wouldn't a hand-crafted input tag be sent via the normal browser HTTP submission process? What mechanism could prevent it from working? How is the request body of from such a form submission different from one where the input tags are S2 custom tags?
These questions are all trivial to explore.
Yes.
You must give them a name; the name will be used to set properties (with correct type conversion) in the struts action.
If you call an input somename the setSomename() will be called on post.
If simple HTML used you wont be able to call struts tags inside it eg:
<s:submit cssStyle="submit_button" id='newrc%{#stat.index}.%{#questionIndex.index}' name="newrc%{#stat.index}.%{#questionIndex.index}" onclick="return newrcClick(this)" value="+" />
This works but below code does not provide values for id and name from values stack thus :name="newrc%{#stat.index}.%{#questionIndex.index}"
<input type="button" cssStyle="submit_button" id='newrc%{#stat.index}.%{#questionIndex.index}' name="newrc%{#stat.index}.%{#questionIndex.index}" onclick="return newrcClick(this)" value="+" />

Why use <g:textField /> in Grails?

What is the reason to use g:textField in Grails if you're already familiar with standard HTML form tags?
If I understand correctly the following two markup alternatives are equivalent:
<input type="text" name="name" value="${params.name}" id="name" />
<g:textField name="name" value="${params.name}" />
Are there any circumstances under which using g:textField would add value? Am I missing something?
The textField tag is provided as a convenience (slightly shorter than writing the HTML input) and is there to provide a full set of form tags. Personally I prefer to write as much plain HTML as possible in my Grails views and only tend to use the tags that really offer a benefit such as the form tag. I have not found an instance where using textField would have added any value outside of requiring a few less characters to type.
<g:textField /> is not shorter as plain text field tag, except id attribute will be attached automatically.
However, I recommend you to use customized tags associating the bean values with input fields. That shortens the code a lot. For more information you can read http://www.jtict.com/blog/shorter-grails-textfield/
Also you can find useful stuff in Form Helper Plugin

Resources