Is it possible somehow to open url, without loading it. Let me explain, I'm creating check-box which will let to create new log and automtically input values. I know how to take boxes and input value into them using javascript. But i don't know how to open that page without loading it on screen OR write that url that javascript would type values into that page.
The concept you should read up on is AJAX. It sounds like it would fit your needs: post our data to a script, let the script do it's job, and work with the answer (or completely ignore the answer)
Since it seems that you are a beginner, maybe you might want to take a look at the jQuery Ajax documentation.
Related
I'm creating a webform using a marketing automation platform. I want to add a field that functions with jquery to do an autocomplete. Unfortunately, the forms are generated through a WYSIWYG editor in the software, and then generated and put into the page when it renders. The only code for the form that appears in the HTML for the page is a simple variable placeholder - %%FORM::DEFINITION%% - which is then replaced with the form code when you visit the URL. The software support team tells me that making the change I want to make is impossible, which I see as a challenge.
The only thing I need to be able to do is add an id="autocomplete-dynamic" attribute to the input on the form. I had two ideas how I could achieve this.
The first, and most preferable option, would be some script that runs at the bottom of the page that simply inserts the attribute into the input tag after the page renders out. This would only be a client-side change, but since all this does is make the text field capable of looking up values out of another table, it should be fine. If someone had a script blocker in place, they would not be prevented from typing into the text field normally, it's just that the auto-lookup wouldn't work. We're trying to make it easier to select an item from a list of thousands of possibilities, but if someone had to type in their own entry without the autocomplete, it would not be a disaster. This seems like a clean solution, but I am not sure if it can be done.
The other possibility is to get the form code out of the software and embed it in a separate HTML document, and make the change there. You can extract the raw HTML for the form for use on another page, but pasting this code right back into the landing page causes errors. So, the thought then was that if I have taken the code generated by the software and put it in an HTML page on a separate web server, I could modify it as needed, and then turn around and use an iframe to stick it right back in the landing page. The software shouldn't complain because the form is being used on an external site like it's supposed to be... I have just hidden that external site back inside the platform-hosted page.
Option 1 would still be much easier to implement, I think, provided it is actually possible.
Thanks in advance.
Your first solution seems completely appropriate.
$(function() {
$('#myForm input').attr('id', 'autocomplete-dynamic');
});
This can be added anywhere inside a script tag because it's wrapped in a shorthand document.ready function, which waits to run until the DOM is ready.
I'm new to Ajax and was told need to use it for what I'm trying to accomplish here.
Here is the website... http://modocom.ca/gillons
If you scroll down up will see a section called Find an Office with drop down menu in it. What I need is for when someone click on for example Emo in the dropdown menu the location info from.... http://modocom.ca/gillons/emo goes under the dropdown and so on for each location in the dropdown and also when your on the Emo page for example you click on the dropdown menu and can choose different location and get new info as well for selected location.
Hope that makes sense and hopefully someone could give me a hand.
Thanks,
Mike
OK, I'm not going to write code as it looks as though you haven't actually tried anything yourself yet.
However, the sequence of events, one version of them anyway, might look like this.
Using jQuery, put a change event on your dropdown.
When the event triggers, and this depends on your backend as you have not spcified APS.Net, MNV, Java etc, you need to post back to a code file of some sort and pass in the value within the dropdown.
From there, in your c#, java, pythod, whatever, code, take that value, generate some HTML and return that HTML to the client.
At the client, you accept the HTML and fill say a DIV with the returned HTML.
If you are using MVC, you can return a PartialView which is a better design.
I'm sorry for the vague title. I'm not quite sure how to word it.
I am fairly new to programming and working on a small chrome extension that checks a particular website for new product listings. I am retrieving the webpage using XmlHttpRequest, however I would like to get the webpage with certain display options already applied.
The webpage I am fetching uses javascript to change its display options. By default, it shows only in-stock items and 20 items. What I want is both in-stock and out-of-stock, and 100 items.
If I go to the website and directly change the options, then fetch the page with XmlHttpRequest, it will return what I want. But I would like to be able to do this all from within the program.
This is the webpage: http://ekizo.mandarake.co.jp/shop/en/category-action-figure.html
Any idea if this is possible and if so, how I could accomplish it? Thanks in advance.
If you look at what happens when you change the number of items to display it goes to this page with the added variables:
http://ekizo.mandarake.co.jp/shop/en/searchOption.do?action=setListCount&keyword=&searchStrategy=keyword&listCount=100
All you need to do is recreate that GET request with the details you want.
(although for the other things such as stock avaliability I have not looked as to where this is)
Firebug is your friend with this kind of thing.
I have 2 pages say index.html and 2ndPage.html.
index.html has two textboxes and a button. Now i want to enter some data in the textboxes and received the data in 2ndpage.html. I want to use only javascript. dont want to use query string. Only post or get method. Is it possible? Please help me or guide me how to send and receive data form one page to another in javascript/jquery.
Well, using javascript or jquery you can accomplish that. Check jQuery's AJAX function. Otherwise, learn PHP as already mentioned in the comments.
using localStorage or sessionStorage you can do this. here is a link, which will help you. i just take few css property from one page to another page. but you can take input value also.
Taking css property from one html page to another page
or if you are taking care of old browser also then javascript Location object is the way to go.
I'm working on a scraper just to take data out of 3 select boxes in a third-party website running on ASP.NET, but the problem here is that they are cascading (not sure if this is how it's called). So what appears in the second select input depends on what's selected in the first one, and I want to get all the possibilities so I can store them.
My problem:
I'm having a hard time figuring how to trigger the change (or whatever) event so it updates the second input. How can I do it?
I'm using casperjs to do this btw, but it doesn't matter, I just need a way to do it programmatically from the frontend javascript.
So, if it works in the chrome console it will work for me.
The form is in this page http://www.tuti.pt/contrat/net/default.aspx and the inputs I'm talking about are the 'Distrito' and 'Concelho'.
Sorry for the long read but I think I couldn't hide more details.
What I've tried?
The usual thing, I really thought .click() would work but not, it didn't so it should be some asp.net special event.
Then I've placed a break and it seems this particular peace of stack seems interesting to find what I need.
Sys.Extended.UI.CascadingDropDownBehavior._clearItems (default.aspx:13)
Sys.Extended.UI.CascadingDropDownBehavior._setOptions (default.aspx:13)
Sys.Extended.UI.CascadingDropDownBehavior._onParentChange (default.aspx:13)
w.createDelegate (ScriptResource.axd:2)
w.addHandler.b.query.each.g (ScriptResource.axd:2)
If someone has knowledge on this I would appreciate to have some help on it.
I just saw there seems to be a method that could be what I'm looking for: raiseSelectionChanged(eventArgs). I just don't know in what object should I call it and what args should I pass :s
This last info took from http://www.asp.net/ajaxlibrary/act_CascadingDropdown.ashx
I wrote a little bit of code to do this entirely from the console in Chrome. Here are the steps:
Run this on the console to include jQuery since that page doesn't seem to use jQuery:
var jq = document.createElement('script');
jq.src = "http://code.jquery.com/jquery-latest.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
jQuery.noConflict();
Now all you need to do is iterate through the options in the select box for Distrito and make a POST ajax request with the following in the request payload:
{'knownCategoryValues':'Distrito:1;','category':'Concelho','contextKey':''} where 1 is the ID of the Distrito, which comes from the value in the corresponding option in the select element. Therefore the function to iterate thorugh them should be as follows:
$.each( $('#ctl00_ContentPlaceHolderMain_SigaWeb_ContrataWizardNet_SigaWeb_BookMetaDadosVeiculos1_Meta_Auto_23 > option')
, function(index,value) {
$.ajax({
url:'http://www.tuti.pt/wsSigaWebSearchContrata/wsSigaWebSearch.asmx/GetConcelhosPorDistrito'
,type:'POST'
,contentType: 'application/json; charset=UTF-8'
,data: "{'knownCategoryValues':'Distrito:"+$(value).val()+";','category':'Concelho','contextKey':''}"
,success: function(data){
console.log(data);}
});
});
So, still not found how to trigger the event, actually now I doubt it's even possible... Maybe if there is a way to get the object Sys.Extended.UI.CascadingDropDownBehavior responsible for that select input, but I have no idea how to do that.
My solution for now is to use the Web Service used by that 'library?' to update the inputs. I found the url for it inspecting he object in Chrome console. Just created a break point for when the second input is changed and when changing the first select it stops there. Then I inspected the CascadingDropDownBehavior object that was in the locals, and found the web service url in _serviceMethod :D
Update:
Ok, so at the end I just programmed a lil ruby script to fetch from the API/WS wich was pretty simple and easy, since there seems be no way to trigger the events from the javascript browser runtime.