Cannot read property 'value' of null" - if-statement

https://jsfiddle.net/kxpzL13v/3/
go and have look on this when you click on a button genrate random story then error is occured .
const name = customName.value;
newStory=newStory.replace('Bob',name);
}```

Your input looks like this
<input id="customeName" type="text" placeholder="">
so the id would be customeName
But you are referencing the input like this
const customName = document.getElementById('customname');
Correct above by adding the correct id customeName as below
const customName = document.getElementById('customeName');

Related

Custom Input Field on Checkout Page in Opencart:3

I want to have a Custom Input field under Payment Method, to get GST Tax detail before placing Order. And I am Using Journal 3 Theme. which has a One-Page checkout.
So, i have tried this article:- https://forum.opencart.com/viewtopic.php?t=172521
At catalog/view/theme/journal3/template/journal3/checkout/payment_method.twig ---added this line
<input name="get_gst" type="text" placeholder="{{ custom_gst }}" class="form-control">
At catalog/controller/checkout/payment_method.php
$this->session->data['comment'] = strip_tags($this->request->post['comment']); //Under this line
$this->session->data['your_field'] = strip_tags($this->request->post['get_gst']); //I added this line
At catalog/controller/checkout/confirm.php
$order_data['comment'] = $this->session->data['comment']; //Under this line
$order_data['get_gst'] = $this->session->data['get_gst']; //I added this line
At catalog/model/checkout/order.php
, comment = '" . $this->db->escape($data['comment']) . "' //after this line
, get_gst = '" . $this->db->escape($data['get_gst']) . "' //I added this line
And After All getting this errro...
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
OK
I have noticed a difference that this theme is getting other field data(Like: Comment box) by v-model="order_data.comment" as shown below, rather than name attribute like i used.
<textarea class="form-control" v-model="order_data.comment" placeholder="{{ text_comments }}"></textarea>
So, i also tried this v-model="get_gst" in my input, but then i am getting an empty checkout page.
Anyone know where is Getting ERROR? Thank You in Advance.
Checkout js file
Seems you not properly add to the session your field.
At catalog/controller/checkout/payment_method.php
This line incorrect:
$this->session->data['your_field'] = strip_tags($this->request->post['get_gst']); //I added this line
Should be:
$this->session->data['get_gst'] = strip_tags($this->request->post['get_gst']); //I added this line
Journal 3 them looks great from the first sight... But I do not recommend to use Journal 3 theme. This theme very complicated and ruining OC framework.
The ease solution - you take any field from payment address, which is currently unused (like Address 2), change it's title to "GST Tax detail" in opencart language files catalog/language/en-gb/checkout/checkout.php.
Address list from Account & Address list under billing details of checkout, Both are taking their data from catalog/controller/accout/address.php in protected function getList(). So, we only need to modify checkout/payment_address.tpl file. Just add
<?php echo $address['address_2']; ?>
AFTER
<?php echo $address['address_1']; ?>
We need to add this because OpenCart only show Address 1 field in Payment method & Billing details section on Checkout page. So, by this we can show Address 2 field on it.

How to retrive comman sperated value from same input feild name in django

I have following html
<input name='Test' value='Maths'/>
<input name='Test' value='PHP'/>
And want to retrieve request data using
Test = request.POST.getlist(["Test"])
Or
Test = request.POST.get(["Test"])
When i am tried this both statement gives error
unhashable type: 'list'
Or if i used simple
Test = request.POST(["Test"])
it only return last value i.e PHP
Is there any other way to retrieve value ?

Salesforce lightning Input with list doesn't work

I'm trying use input with datalist in a lightning component and doesn't seem to work. I've looked around and can't seem to find anything that says i can't. So basically,
<input list="acctlist"/>
<datalist id="acctlist">
<option value="somevalue">
</datalist>
does not work. I want to have an input in a form that a user can type but also able to select from a list returned from the controller. Is there a workaround that would be as simple or is this the following route the best i got.
https://developer.salesforce.com/blogs/developer-relations/2015/06/salesforce-lightning-inputlookup-missing-component.html
The list attribute of input tag is not compatible with lightning component.
When you deploy the components, the attribute is removed.
If you want to use input with datalist, you need to add the attribute in Renderer.js.
datalist.cmp
<input aura:id="acctlistInput" />
<datalist id="acctlist">
<option value="somevalue" />
</datalist>
datalistRenderer.js
afterRender : function(component, helper) {
var acctlistInputCmp = component.find("acctlistInput");
var acctlistInput = acctlistInputCmp.getElement();
acctlistInput.setAttribute("list", "acctlist");
return this.superAfterRender();
}

How to post a array to views.py

I am using for loop in my template and for different id of each record i am using arrays
{% for item in product %}
<div class="register_div">
<p><label for="id[{{ item.id }}]">{{ item.Name }} </label> <input type="text" name="custom[{{item.id}}]"/></p>
</div>
{% endfor %}
Now when in my views i want to save this data to my database.But firstly i checked that whether my array return something or not.So i just try print that as.
q = upload_form.data['custom[]']
or
q = upload_form.data['custom']
but it gives me this error
"Key 'custom[]' **OR** key custom not found in <QueryDict: {u'custom[2]': [u's'], u'custom[1]': [u'a'], u'price': [u''], u'title': [u''], u'customatt': [u'', u''], u'csrfmiddlewaretoken': [u'up4Ipd5L13Efk14MI3ia2FRYScMwMJLz']}>"
but if i print this
q = upload_form.data['custom[1]']
then it display the value of array 1.
so please suggest me a better way to do this how i can display all values inside my array in views.py
As upload_form.data is a dictionary, the key 'custom[]' simply doesn't exist. Try something like:
custom_values = {}
for key, value in in upload_form.data.items():
if key.startswith('custom'):
custom_values[key]=value
The dictionary custom_values holds now all your 'custom' form values.
This is not an answer to question, but:
You are not posting an array, but different inputs whose name looks like accessing array. e.g. you are posting different input variables named custom[1], custom[2] etc. But custom is not an array, you will have to access inputs as custom[1] etc.
I'm not sure you want this or not!

How to encode HTML form in coldfusion?

I'm new to coldfusion.
I have page called test1.cfm
<form action = "test2.cfm" method = "post">
Type your name and hit submit:<br>
<input type = "Text" name = "txt1">
<input type = "Submit" name = "" value = "submit">
</form>
And test2.cfm
<cfoutput>
success
#form.txt1#
back
</cfoutput>
Now I want to know if we can encode the displaying of text value in test2.cfm page.
For eg. if we type <br> in the textbox, test2 page will render it as html, and I want to stop rending and it should display as text.
Thanks
It's HTMLEditFormat(), not code.
Use
#htmlCodeFormat(form.txt1)#