c# QueryString how to send data from one webpage to another? - javascript

I wanted to ask a little complicated question for me. I want to make a simple program like I have website www.example1.com and there would be a simple panel to enter your name and your country. After that you have to click "send" and it will give you a request number like 12345. The data entered on that panel will be sent to the another site at wwww.example2.com . And I will check the data given from example1 to example2 (like: name: John , country : Jamaica , request number :12345) . I found on internet something like querystring at c# but im not sure what to do. I demand your help , best regards.

Yes this is possible you could navigate the browser from site www.example1.com to www.example2.com/someAction?name=joe for example. However, in order to validate against this you would need some sort of server in which example1 would have to send the data first and store it. This would then allow example2 to call that service checking the data it got via query params was valid. This is a very long winded way to pass data about not sure it is a good solution.

Related

How do I get a value from html and post it?

im a begginer web developer and i want to make something like that:
you login with username end password, then it redirects you to the home page, and says something like this:
Hello (username) welcome!
but i dont know how to read the value from the input please help
i searched it up but it only showed a search input option
This is too generalized for such a question. Many questions: -Are you using any backend? If so which one (what language? And what kind of database (ie SQL etc.))?
To store data you need a backend or at least use frontend js's localStore (would work if every page is on the same domain and server).
Yet another front-end way would be to pass the information as url-parameters and get them.
But if you really want to build a robust login system of any kind, the best way is to use backend (PHP/node JS/Java/python etc.) and store the data in a database (SQL etc.). And make sure it is secure, but security is too broad of a topic for this question.
Your asked very generalized question, for my assumption there you want to do either one of these
when you login, you want to keep username from input and and redirect the user to home page and show the username on the label like hello abcd
You have an input field with username on home page and want to show the text of the input field into label
so, I will give answer considering the above scenarios, the answer will be considering how I will do things(as I don't know what you are using in backend the answer may vary)
for point 1 I will store the username in a localstorage, sessionstorage or cookie.
let's say I used sessionstorage, the below code will be performed on my login button click
sessionStorage.setItem('quantity',document.getElementById('username').value);
and on my pageLoad of home page I will set the value in my label like below
document.getElementById('lblusername').text = sessionStorage.getItem('quantity');
option 2,
on my home Page I will simply get the value from input field and show it on label
document.getElementById('lblusername').text = document.getElementById('username').value;
let me know if it helped you as I don't know your exact scenario

How to get part of a link and input it into website with javascript

So I'm trying to make a website where you put in a username and it will give you data about that username using an API. Right now I have it set up so you have to type the username in every time you're on the website, but I was wondering if it's possible to put the username in the link and still be able to retrieve it to put it into an API and use the API's response in the website?
For example, would it be possible to have something like http://website.com/?username=XXXXXXXXXand to be able to get the part after ?username= and to save it to a string or something to put into the API using JavaScript or jQuery? Any help would be appreciated :)
why don't you saving username in cookie/storage/session after user input?your ways is complex and unreliable.or may be you could use the rest url format like this: http://{username}.example.com/api or http://www.example.com/{user}/api then your backend always retrieves username from this path and you needn't add parameters manually.

How can I make a search box to search in a local database?

I'm playing around with Apache Cordova and I want to implement a search box that can search in a list or something similar (local database?). I want it to be local so that the app does not require an internet connection to search.
The way I want it to be set up is that it need to be able to search for both the name of the item and a number.
Example 1:
A user searches for: "Honda". He will then be sent to a page where information about "Honda" will be diplayed.
Example 2:
A user searches for the id: "1337". He will then be sent to the page containing information about "Honda".
So "Honda = 1337" and "1337 = Honda" if you guys understand?
The question:
I'm wondering what solution would suite my needs for this project?
or there any frameworks out there for this?
Thanks in advance!
It depends on what you want to have the search box and submit to be like.
One way is to use this really great tool http://ivaynberg.github.io/select2/ it can load data from database (using either ajax or load all of your data and only filter them) and shows them in selectbox. You can have submit button or something like that next to your selectbox.
Other way might be to use http://www.datatables.net/ it has search box, which can load data to table using ajax where you can have additional information and submit button for sending user to specific page.
There is plenty of other tools for this kind of problem, I used these two and I can say

How do I populate form fields on a page from a database based on the page url?

Hello first I’d like to say, please excuse my ignorance to this all, as I’m very new to this all. I just started and still trying to understand this.
So far I have a database set up and I’m trying to retrieve values from a database to fill in a form on a page when it loads. The record or row/values that need to be retrieved from a database depend on the page’s URL.
I’m ok with html and css but still trying to learn more about jquery, JavaScript, sql, php and so on and so forth. I realize I have a ways to go and honestly some of the guides and tutorials online are kind of confusing because everyone has a different way of coding. So I’m a bit confused.
I’ve included a simple chart to breakdown what I’m trying to do.
If someone could point me in the right direction I’d be really grateful! Thanks.
If I understand you well, you want to setup a form and populate some fields of this form with a query forms a database, the primary key of the record being relative to the url.
The first step is to build the url, you can pass some parameters to an url by adding a ? at the end of the url followed by the parameter name, the = sign and the parameter value. If you have more than one parameter, you should separate each parameter with the sign &.
So your url could be something like this :
www.examplesite.com/page&.html?key=key_A1
Then, you'll have to choose if you want to build the page on the server side with a language like php, in which case you retrieve the parameter, query the database, build the html form and send it to the client.
You can also go client side with plain javascript or jquery, in which case you will still have to do some server side programming to query the database but will use an ajax call to get the data and will populate the fields in Javascript or JQuery.
You can do this using Javscript(using Ajax)
U need the key to search for get the results from database
Using ajax call get the data, You might have to write code to get the details from database using any server side prog language
Using javascript to fill the form input with the received data.
Google for jquery ajax examples, and how to populate input using javascript.
There are many frameworks out there that have DataBinding built-in that do the same job a lot easier. My favourite would be Angular Js, you can try Ember and lot more out there, choose the one you feel comfortable with.

ajax auto comlete problem

Q:
I want to make autocomplete facility like the one exists in yahoo mail ,
when i write a mail address then i post it by(;)
i see a list of mails begin with specific character , when i tried the ajax auto complete i face a problem ,when i write a name and post it by(;)and begin to write the second name , it concatenate the first one with the expected instances of the second one in the auto complete list. i want the same action in yahoo mail how to do this.
(no concatenation in the auto complete list)?
If you want a simple effective solution you should have a look at jQuery UI automcomplete
It quite easy to implement and it allows you to format the result the way you want; changing, for example, the , in ;
You can find some code here
You could use what Yahoo mail uses:
http://developer.yahoo.com/yui/3/examples/autocomplete/ac_local.html
http://developer.yahoo.com/yui/3/examples/autocomplete/ac_datasource.html
How to get the information from your database:
http://developer.yahoo.com/yui/3/datasource/

Categories

Resources