I am creating multiple user in Django site - django-models

register form select user then automatically show user header id
how to get selected data in form before submit
how to check a condition selected user = header and get value in Django
view function work but how to get form data in before submit in template

Related

i have put refferal id in form input feild which is present in url

I have created a referral link in my angular project which has carry a referral id when I copy that link and search on browser I want that referral number in the input field of the form on that page. Can anyone tell me the solution
i had with save this referal link in variable and display in interpolation but in form field referal link is not showing

How to store the cookies from one session and restore the same cookies by refreshing the page in AngularJS?

I have two input item one for the Option Select and Radio Button. Once the user selects the Option Select (say, the value is ABCD) and Radio button (say, the value is R).
Now the user refreshes the page and would like to pre-populate the page with a default value of Option Select (ABCD) and radio button (R).
I have been trying to use ngCookies. I can set and get the cookies from the same session. Once I refresh the page, the values become null.
such as $cookies.put('selectOption', $scope.selectValue) $cookies('radioSelection', $scope.radioValue)
TO get the value, $cookie.get('selectOption') and $cookie.get('radioSelection');
Basically, recreating the page with some default values.
Please help me out how I can achieve this one.
I guess you are resetting your select box value each time you refresh so add an if statement like
if (!$cookie.get('selectOption') ) {
$cookies.put('selectOption', $scope.selectValue)
}

Switch between nav-tabs on the successful submission of the form

I have 2 nav-tabs , one of them shows the list of available items and the other tab gives a form where you can add the item details.
All the item details gets saved in database of submission of the form. If there is error the form submission fails and we send out 500 error code.
Now the problem is when i submit the form and the details are saved in database successfully i want to change the tab from Create to Edit.
Can anyone please tell me how can i achieve this?

Drupal Webform - How to load values from form, filled in a previous page

Working on Drupal, I have a page with a form made with "Webform" module, containing several fields (text fields and sliders) and a "Submit" button.
When the user enters the information and presses the "Submit" button, another page is loaded with custom code into it.
The new page is devided into 2 parts - the first one contains new information(based on the user input from the previous page); the second one contains (block) the same form, used in the previous page.
Is there a way to load the values, filled in the form from the first page into the new page?
First of all you would need to make a custom module, with the help of
hook_form_alter
You would need to store the previous form's information in cookies with prefix
Drupal_visitor_
and then display it in the new page like:
$form['submitted']['FirstName']['#default_value'] =
$_COOKIE[$firstname];
Thanks

web2py - Dropdown menu

I'm trying to have a dropdown menu for the user to select the database table. I have defined few tables in db.py and I want the user the to select a particular table from a dropdown menu and insert entries. Right now I use SQLFORM:
def index():
form=SQLFORM(db.selectedtable) #want to change the table name#
if form.process().accepted:
response.flash = 'form accepted'
elif form.errors:
response.flash = 'form has errors'
else:
response.flash = 'please fill out the form'
return dict(form=form)
I need the user to select 'selectedtable' value from a dropdown list that shows all the available tables in the DB. I do not necessarily want to retrieve the table values from DB. I am OK with defining a list with the available tables and the dropdown menu can pull the table names from that list.
So far I only found IS_IN_DB to automatically create a dropdown and PluginDropdown() but that does not serve my purpose. If soemebody can direct me to the proper way of handling this task I'd be really thankful.
Regards.
Update:
After Anthony's suggession I tried the following with , as I'm not that familiar with JS.
{{extend 'layout.html'}}
{{select='NONE'}}
<form>
<select>
{{for item in TOOLS:}}
<option value="{{select=item}}">{{=item}}</option>{{pass}}
</select>
<input type="submit" value="Go!"/>
</form>
<h2>Input form</h2>
{{=form}}
<h2>{{=select}}</h2>
As you might see this doesn't work properly. What I tried to do is to get the user chose value to 'select' variable. But it doesn't work. It always gets the last element in ITEMS (this list is defined in db.py). My next option would be to be call another controller function, passing the user selected value as an argument. Then it can prepare the form with the passed value and send to a view to display
<h2>Input form</h2>
{{=form}}
But I'm not sure how I can assign the user chosen value to an argument and then call another controller function with that arugument value.
If you have any suggestion how I can modify this to get the user chosen value thats very much appreciated. Thank you.
You could create a <select> element listing all the tables, and then load the form associated with the selected table as a web2py component via Ajax. In the view of the main page (e.g., /views/default/index.html):
<script>
jQuery(function() {
jQuery('#table').change(function() {
web2py_component("{{=URL('default', 'form.load')}}" + "/" +
jQuery(this).val(), target='form')
})
})
</script>
{{=SELECT('Select a table', *db.tables, _id='table')}}
<div id="form"></div>
And in a controller (e.g., default.py):
def form():
if request.args(0) in db.tables:
response.generic_patterns = ['load']
return dict(form=SQLFORM(db[request.args(0)]).process())
else:
raise HTTP(404)
Note, db.tables is a list of all the tables defined on the db connection object -- it is used in the SELECT() helper in the view to generate a <select> list of all the tables. The script in the view registers a jQuery event handler that fires whenever a different table is selected from the dropdown. The handler calls the web2py_component() function (which is in /static/js/web2py.js), which loads the form component via Ajax into the div with id="form". It appends the value of the selected table to the URL.
In the controller, the form() function checks for the db table name in request.args(0). It then sets response.generic_patterns so the "generic.load" view will be allowed (by default, generic views are only enabled for local requests). Alternatively, you could define your own "form.load" view, or even use a different extension (e.g., "form.html").
Because the form is loaded as a web2py Ajax component, the form submission will be trapped and submitted via Ajax as well, so it will not result in a full page reload.

Resources