Javascript: Get radio-button value from another html page - javascript

Hi everybody!
Background:
I currently build an online unit-converter which be can be seen under
http://okconvert.com/index.php?option=com_content&view=article&id=126&Itemid=1262 .
In the bottom left corner you find an orange button named "Conversion Settings". After a click on this button, the user shall be able to select how exact his unit conversions shall be. He/She chooses an accuracy (for example 3 or 4 digits), then clicks "Apply settings".
When the user actually does a conversion afterwards, he clicks on the button "Ok, convert!" and a javascript is called which calculates results.
Question
Which would be the smartest way to access the value of the selected radio button from the pop-up in the javascript?
I googled a lot and found some answers but none of them really seems to suite my needs. Here are two possibilities I'm considering:
Using HTML5 local storage (I need to have a default conversion-accuracy, so this might not be useful because applying conversion settings shall only be optional)
Using jQuery/Ajax to load the custom html and use some kind of GetElementbyID for the loaded page
Additional information
After clicking on the orange button, a "JCE Mediabox" is opened which is filled with some custom html. The pop-up actually links to the custom html page, so I could access that url if needed.
I have some basic knowledge about javascript, html and css but have never used jqueries/ajax before.
Any help or hints would be highly appreciated!
With best regards,
Felix
http://www.okconvert.com

How about dropping the value in a cookie. It's simple enough, keeps the state on the client and works over all windows and popups you care to open.

Related

Chrome Extension Popup Questions

I'm trying to make a bot for a website, to make purchases faster and automated. In order to do so, I am using javascript (atom) and chrome extensions. I need some help with the following things to do with chrome extension popup, which will improve the UI of my program (user interface)
1.Is there a way for the user to set a time for the code to excecute at? For example, a 24 hour clock they can edit using text boxes in the popup. Maybe this triggers a new tab which has a coutdown clock, at the end of which the code is excecuted on the website.
2.Can I create text boxes, so that the user can fill in various details such as item name and size value, that can be integrated with my main javascript code to change which product is purchased by the bot?
3.How do I create dropdown boxes for things like the category, with multiple options. Again, this must correspond with the main JS code.
4.Can I create a login page that must be filled in with a unique login before the user can access the main login page?
5.Can I create little switches?
6.Is there a way for me to customise the buttons with certain fonts, colours and sizes, and to customise the backgroud colour etc. I really want it to pop!
I know that this is a lot of questions, so please feel free to answer one or two rather thatn all of them! I have an incredibly basic understanding of HTML, so I may have some followup questions for you.
Thanks in advance,
Louis

How to create a page location in browser using javascript/jQuery?

I have a setup where I display a list of buttons and clicking on the buttons triggers a function that contacts a firebase database and gets the contents of a 'slide' that is to be shown to the user. The function then clears the content of the page and then creates elements from the data acquired from the database.
Now obviously, when I press back browser button once I've replaced the content, it won't take me back to the previous content. But I believe that my user's experience will be much better if it actually took them back to the list of buttons. I have two faint ideas on how to go about solving this problem but I'm lacking in specific details of how I can go about it.
Possible Solution 1:
Some way to dynamically create a new page using javascript and then serve it to the user.
Possible Solution 2:
Some way to simulate that the page has changed location. Maybe using anchoring links.
Let me know if you have any other solutions in mind or if you know how I should go about implementing these. Your help will be much appreciated. :D

What the functionality is called which is used while logging out of Google account?

When we want to log-out from the google/gmail account, we click on the profile picture displayed at the right most of the Google bar. The scenario with the pop-up is shown in below figure.
What does this functionality called in jQuery, HTML? I think it's not a modal pop-up as it's not appearing on the existing content of a page and background content is non-clickable. Also it can't be called as tool-tip as it's not showing up on mouse hover, we need to click on profile picture to see the log out button. So what does it called?
I'm asking this thing curiously because I need to implement same functionality in my website. That is when user clicks on specific text the pop-up/tool-tip(for now I'm using these words for your understanding only, may be I'm using wrong words). As I don't know the exact word for this functionality I'm not able to find out such jQuery plugin on internet which would behave the same way.
One more thing is that I want to use a form in this pop-up/tool-tip which would be submitted to PHP using AJAX.
Popover!
Example API from a popular CSS/JS toolkit:
http://getbootstrap.com/javascript/#popovers

How do I build a multi-stage web form?

I'm trying to build a webform that has multiple stages. I'm patterning it off of the Stack Overflow / Stack Exchange flagging webform. The problem is, I'm not sure how to trigger the "next stage" action.
To illustrate, if one wants to flag a question on Stack Overflow, you click flag and then a popup prompts you to make a choice. If you choose the second option ("it doesn't belong here, or it is a duplicate") the form automagically takes you to a second screen.
First screen:
Upon click, it auto-redirects to:
The problem is that I don't know what the underlying trigger is. How does clicking that radio button send the end user to the next screen?
I tried checking the source, but I have a feeling I'm only seeing half the picture:
No amount of HTML tutorials I find have any practice example similar to this. I suspect this is JavaScript, but I can't find the linked .js file that would trigger these actions.
So: How does the webform auto-redirect upon click? As a follow-up, if it's using JavaScript, is there an HTML/CSS-only workaround I can use?
It might help to think about this at a lower level than frameworks. There are two ways one could make a multi-stage form.
The first (and generally older) way is to store the state on the server. Each stage of the form is actually a separate form, and the client's progress through the questionnaire is kept on the server (for example, as part of the session data).
The second way (the more modern one) is to use JavaScript, as you suspected. There is actually very little black magic in this case, and no auto-redirects on clicks at all. All you do is have one very long form where you show/hide some of the elements depending on the user's selections (of course, you could have multiple <form> elements which you show/hide).
Well, I'd use some sort of jQuery wizard plugin and adapt it to my needs. I did it very recently and it wasn't that hard. You should try SmartWizard 3.0, it's pretty active, the last release was about 2 months ago and the coders answered my questions pretty fast.
Here it is: https://github.com/mstratman/jQuery-Smart-Wizard
You can trigger the wizard to advance to the next step linking an event to the action of clicking the radio button.
Good luck :)

How to enter text into the "Write something..." box on Facebook and click Submit

I am trying to manipulate Facebook pages in various ways, using Javascript browser elements. I'd need to be able to insert some text into the top "Type something..." box that shows on my site's fan page (or alternately, "click into" the field and I can type the text using GUI scripting), then click the "submit" button as if i'd done it by hand. It's tricky since the page is very Ajax heavy and I can't find the names of the elements I need to manipulate, let alone how to manipulate them as they're not using traditional form fields I'm used to. Can anyone help me figure out how to do this with javascript commands, which I'd be calling from Applescript on the Mac?
Many thanks in advance.
UPDATE
Thanks for the comments below. Believe me, I am not trying to do anything spammy or douchy, mainly posting links to products that have gone live on page facebook page, but do it during the business day when people are on rather than at strange hours of the day. I am located in Japan so my sleep period is right when people are using FB.
The solution I came up with for clicking the button was got using UI Browser, an outstanding tool if you're trying to script on the Mac. The script that clicked the button for me was:
tell application "Safari"
activate
set thename to name of (get current tab of window 1)
delay 3
tell application "System Events"
tell process "Safari"
try
click button "Share" of group 1 of group 2 of list 3 of group 9 of UI element 1 of scroll area 1 of group 3 of window thename -- this one works on the mini?
on error
click button "Share" of group 1 of group 2 of list 3 of group 9 of UI element 1 of scroll area 1 of group 2 of window thename -- did not work
end try
end tell
end tell
end tell
Hope this is useful to anyone.
You can't. But even if you could you want to post comments on peoples behalf and expect them to continue using your site...
It would be cross site scripting - and since the comment box is in an iFrame it actually exists on Facebook's site and not your site.
Manipulating web pages for functionality is rarely a good idea, since you can introduce bugs and security flaws.
In this instance, if all you want to do is post a status, just use the Facebook API thats what its there for. They provide libraries (I think, at the very least they are available) to make it easy to use whatever language you want.
From a UX PoV, people don't like being forced to post things, so if this is just for your use, then fine, otherwise, make sure that people know whats going on. Its only polite.

Categories