How to select current logged in user to my selected option value - javascript

I got an interface, already logged in with a new username now I want so select this user to my selected option value and insert it into Mysql DB:
<select name="name" class="form-control" required="required">
<option value="" required="required"> Please select </option>
<option value="Rifadije Mavriqi"> Rifadije Mavriqi </option>
<option value=" <?php
?>"></option>
<option value="Merdiana Leci"> Merdiana Leci </option>
</select>

Let say that your working with CronJobs that every X minutes check whos online, than select the column where online=1 with simple while and you got it.

Okay, i dont know if you ever work with cronjobs, thats really easy, via your cpanel/direct admin you pick up a file and set-up every x time the server will run this file. Let call this file cronj.php and there write a query that set all the online colum to 0 ( than unactive users resets) and close the file. I will add in a config or header file a query that check if this is user or unregister guy , if register lets set online colum to 1. And now via your control panel write select query with while that show you where online=1 and show you by the online colum the user names that online right now.

Related

Replace HTML Select Value with Data from Backend

I trying to do something really simple, but I don't know how.
I have an HTML Input select field in a table. If someone writes data in the text field or choose an option from the select field and press the submit Button, the data transfer to the backend via HTTP post. In the backend, the data gets stored in an SQL Database. After that, the page reloads all the textfields having the new value that I reload from the backend and transfer to the Frontend.
Now I am trying to do the same with the select input field. I don't want to use a new label to show what has been the last submitted value (the last row of the table in the attached picture). The last submitted value should be shown in the input select field.
I try to load the values stored in metadata with the value=" " parameter but that doesn't work. In the normal input text field, it works fine and I get the result that I expected.
Can anybody give me an idea to realize this? My current Code looks like this.
{%for i in range(0, len)%}
<tr>
<td>{{i+1}}</td>
<td>{{tables[i][0]}}</td>
<td><input type="text" name="devicename_{{i}}" placeholder="Gerätename" value="{{metadata[i][0]}}"></td>
<td><input type="text" name="place_{{i}}" placeholder="Standort" value ="{{metadata[i][1]}}"></td>
<td>
<select name="devicetype_{{i}}" value ="{{metadata[i][2]}}">
<option>Bitte wählen</option>
<option value="Option1">Option2</option>
<option value="Option2">Option2</option>
<option value="Option3">Option3</option>
<option value="deaktiviert">deaktiviert</option>
</select>
<td>"{{metadata[i][2]}}"</td>
</td>
{%endfor%}
Current Frontend result
Thanks for the help. If I have to use JavaScript or PHP for that, please give me help with javascript.
Can't you just use PHP for that, I have a methode but it's only PHP

jQuery-Calx Auto Calculate

We have a registration form that uses jQuery-Calx to auto calculate the total of the selected items and would like to store the option value in a database after the form is submitted.
How should we define the value used in the calculation to do so? We want to calculate but also want to store “Event Name” if chosen into the database.
We have made some progress trying to follow comments here - http://www.xsanisty.com/project/calx2/comment-page-2/#comment-5678
Here is one of the drop down menus:
<select class="form-control" name="####" data-cell="A1">
<option value="0">Please select</option>
<option value="Event Name 15" data-next="15" >Event Name $15</option>
<option value="10">Ten</option>
</select>
Here is script (not working):
$('#registration').calx({
data:{
A1:{ value: $('[data-cell="A1"]').attr('data-next')}
}
});
We are trying to calculate the total of 5 drop down menus based on the "data-next" value instead of the select option value.
So we can then enter the option value "Event Name" into a database using php (we know how to do this part)
Thank you for any help.

Angular2 ngFor - set selected

When a user logs in to my app, it loads the previous UI setup that they were using. To switch between interfaces there is a dropdown that lists all the options that specific user is authorized to use.
I would like the selected option in that list to reflect the previous UI when the page is loading but I'm having trouble coming up with how to set the selected <option>
Here is some example code:
//User object from DB
var user = {
username: admin,
previousUI: 'Build',
authorizedUI: [{title:'Default'}, {title:'Edit'}, {title:'Build'}]
}
html:
<form class="navbar-form">
<label>System: </label>
<select (change)="systemSelect($event.target.value)">
<option *ngFor="let system of user.authorizedUI" [value]="system.title">
{{system.title}}
</option>
</select>
</form>
In Angular2 how do I set the selected parameter on the option to reflect user.previousUI?
I tried adding this:
<option *ngFor="let system of user.authorizedUI" [value]="system.title" [selected]="system.title === user.previousUI">
But that didn't seem to do it.
One way would be
<select [ngModel]="user?.previousUI" (change)="systemSelect($event.target.value)">

Play framework: update web page when a value is selected from drop down

I am using play framework for the first time.
I want to update the web page when a value is selected from drop down with out refreshing the web page.
Consider the following example:
<select>
<option value= "Apple"> Apple </option>
<option value = "Banana"> Banana </option>
</select>
When a value is selected from drop down it should be posted to server. Then server should return some information based on the value it got. Now we should display the content corresponding to the value selected from drop down with out page refresh.
I didn't find a way to implement this using play framework. Conventionally we can do this by hiding a div initially and when a value is selected from drop down we can add content (fetched from back end) to the div and show it. I didn't understand how to implement the server side part. In play framework, controller generally returns Result type. How to return a Json value on a request in play framework ?
Can anyone please suggest other ideas ??
Thanks
A solution using jQuery (see change() and load()):
<select id="select">
<option value="Apple">Apple</option>
<option value="Banana">Banana</option>
</select>
<div id="result"></div>
<script>
$('#select').change(function() {
$('#result').load('/foo/bar?fruit=' + $(this).val());
});
</script>
EDIT: To address the JSON/server-side part of the question have a look at ScalaJsonHttp (or JavaJsonActions).

Show selected option based on variable

I'm a pretty novice programmer who is trying to implement something I thought would be pretty simple, but after searching haven't found a solution.
So right now I have an variable called msg. msg is dynamically generated and can be anywhere from 2-999.
I have a select that is very simple:
<form method='post' class='myForm' action=''>
<select name='locationSelect' class='locationSelect' data-param='location_IDNUMBER'>
<option value='1'>Exam Room</option>
<option value='2'>Exam Room 2</option>
<option value='3'>X-Ray Room</option>
<option value='1000'>Check Out</option>
</select>
</form>
My problem is: lets say msg has a value of 3. How can I show the select with a value of 3, so the selected option(the option first visible before clicking the arrow) is X-Ray Room?
my code (taken out of a larger block of code is:
$e.find('.locationSelect').show();
How can I modify it to say something like:
$e.find('.locationSelect':value=msg).show(); //this would show the .locationSelect with the selected value being the one with the id of 3, or whatever msg is
Thanks for any and all help! If you need any more details, just ask!
Try
$e.find('.locationSelect').val(msg);
http://jsfiddle.net/mowglisanu/ktcgy/
You can use $.fn.val(value) to set the selected value of a dropdown.
Note that in case you pass to $.fn.val a value that is not present in the dropdown, the first option will be selected instead.

Categories