I am facing an interesting problem: I have a form where I want to insert old values (if the form was submitted before) like this:
<input type="text" :value="oldName" id="name" />
Now the problem is that I can't overwrite the oldName variable like this, so yes, I have the old value in there, but I can't change it anymore. Can you think of a solution? I basically want the value to be in the textfield, but I want the user to be able to change it. Thank you!
Sounds like adding v-once to the input field would solve your problem. V-once means that oldName will be used to render the value once, but after that it will be a normal string literal.
<input type="text" :value="oldName" id="name" v-once/>
In case you want the user to be able to modify the value use v-model instead of v-bind. V-model provides two way binding so when the user writes something in the input field it is reflected in the value.
<input type="text" v-model="oldName" id="name" v-once/>
Related
I used a select dropdown that is filled dynamically, based on conditions on country>state. But I can not get it out on context for the backend to properly save it to the database (selected value).
I can show the dropdowns correctly and save differently and correctly if I use a asp dropdownlist. Thing is, this code is imported and apparently all I can use if the select value.
<label for="country" class="col-form-label">Country: </label>
<select name="txtAddress_Country" class="countries order-alpha form-control" id="txtAddress_Country" runat="server">
<option value="">Select Country</option>
</select>
<label for="txtPersonal_FirstName" class="col-form-label">State: </label>
In the backend... this function works wonders with dropdownlist and text.
dbCampos.Save(u, new ASF.HC.JobApplication.Entity.Campo("txtAddress_Country", txtAddress_Country.Text));
So I am guessing the place to modify is the frontend.
I am guessing that I am missing some attribute but can not seem to find it. Says that it does not contain a definition for "Text" or accepting a first argument.
Maybe an initial value?
It is better to use instead of html with runat server.
secondly you can try as below:
dbCampos.Save(u, new ASF.HC.JobApplication.Entity.Campo("txtAddress_Country", txtAddress_Country.SelectedValue));
instead of:
dbCampos.Save(u, new ASF.HC.JobApplication.Entity.Campo("txtAddress_Country", txtAddress_Country.Text));
I have a privatemsg module in Drupal 7, which uses autocomplete in field "To" (Do is polish translation). It looks very unattractive and I see no option to customise it unfortunately! I checked the code and I tried to modify it, but it doesn't work :o
<input type="text" id="edit-recipient" name="recipient" value="" size="50" maxlength="128" class="form-text required form-autocomplete" />
<input type="hidden" id="edit-recipient-autocomplete" value="http://niemiecki.dogadajsie.pl/messages/autocomplete" disabled="disabled" class="autocomplete" />
As we can see the autocomplete has id="edit-recipient-autocomplete" and class="autocomplete". When I modify it, it just doesn't work in any way. When I tried to search for reference to this id or class I found nothing. Can somebody tell me how to customise it?
Actually it looks like this:
http://i.stack.imgur.com/r6Gej.png
Kind regards, Michael.
What you are trying to modify with the field? You can use hook_form_alter to modify the field. The auto complete class is added because its explicitly set for auto complete.
I have a form within a repeating region that I would like to have two buttons on.
I currently have one button (an image) that submits the form and generates a preview of the record. I would like to add a second button to the same form that performs a different function. I have assigned different names and values to each of the image buttons but how do I retrieve that value and either do a corresponding response.redirect or perform an additional function?
I know in PHP you can use the $_GET["getvar"]; or $_post["getvar"]; but i am using classic asp.
Any help would be greatly appreciated!
example for you
<input type="hidden" name="PageAction" value="" />
<input type="image" name="button1" src="imgage1.jpg" onclick="this.form.PageAction.value='function1';this.form.submit();" />
<input type="image" name="button2" src="imgage2.jpg" onclick="this.form.PageAction.value='function2';this.form.submit();" />
then you can retrive the value of request("PageAction") to seperate diffrent actions,like:
if request("PageAction")="function1" then
call function1()
elseif request("PageAction")="function2" then
call function2()
end if
Request.QueryString("getvar") is the equivalent of $_get and Request.Form("getvar") is the equivalent of $_post.
Where getvar is the name of the button, it will return the value.
How would you go about Restricting Keyboard Input on a textbox using Jquery?
If you don't want the user to be able to type anything in the text-box, then consider the readonly and disabled attributes. If the data in the textbox is needed at the server side, make it readonly. If not, make it disabled.
<input type="text" readonly="readonly" />
<input type="text" disabled="disabled" />
If you want the user to be able to type in something, but only restrict certain types of characters such as numbers only, then listen to the keyup event on the textbox. It is fired whenever a key is released inside the text box. On this events callback, check the value of the textbox, and make changes to the value as necessary.
for <input type="text"> use attribute maxlength
What is the right way of creating and processing a group of related controls on posted forms?
From using ASP.NET MVC I see a standard option is to create a number of inputs and assign the same "name" attribute value to them. Like this:
<input name="OrderOptions" type="checkbox" value="1" />
<input name="OrderOptions" type="checkbox" value="2" />
...
<input name="OrderOptions" type="checkbox" value="N" />
And when processing forms we get all the values in a comma delimited string:
public OrderController
{
public ActionResult (FormCollection form)
{
string selection = form["OrderOptions"];
}
}
Now, is this how it is supposed to be done with any server technology? Does assigning the same name value to inputs break some validation rules or something?
One extra question: If I were to use the built-in HTML helpers, I would get the inputs generated with both "id" and "name" attribute. Like this:
<input id="OrderOptions" name="OrderOptions" type="checkbox" value="1" />
<input id="OrderOptions" name="OrderOptions" type="checkbox" value="2" />
...
<input id="OrderOptions" name="OrderOptions" type="checkbox" value="N" />
But it is clearly invalid to have multiple elements with the same "id" in a document. Still, it works.
If I discard the standard helpers and make my own, do I need to insert the "id" attribute to inputs if I do not really need it (except in some label cases)? Some folks are telling we have to always assign both "id" and "name" attributes to elements because there is some incompatibility with old browsers, and the "name" attribute is deprecated (I know it is only for some other elements). But even if I wanted to, I would have to assign different id/name values for input elements and then I cannot process them as a group. You see my dilemma?
Any advice is greatly appreciated.
a) No. Assigning the same name is definitely valid behaviour -- it's how radio buttons know which group they're a part of (so that others in the same group turn off when you click one, while other groups on the same page are unaffected).
b) Yes, having the same ID is invalid. I have the same problem with the helper apps. It makes the entire page invalid and, for me at least, makes any javascript more difficult.
No, you don't need the ID. But if they exist they should be unique. Furthermore, I don't know about this whole "name being deprecated" thing. How else will forms work? Forms do not submit the ID when POSTing back. See http://www.w3.org/TR/html401/interact/forms.html#edef-INPUT .
If you choose to assign ID, they can be different without affecting group_processing. In fact, I'll generally name them something like "OrderOptions-<%= order.option.id %>".
EDIT:
PS: Use the html validator at http://validator.w3.org/#validate_by_uri+with_options . It'll catch and notify you of things like duplicate IDs or missing IDs. It'll also (if I remember correctly) tell you of deprecated elements/attributes that you use.
James