0

I'm not very familiar with code but am stuck with a project attempting to take the javascript variable from a webpage and pass it into a web-based application (Lectora) to use further. The application allows External HTML Objects to achieve this but I do not know much on topic beyon using it for iframes.

2
Contributors
10
Replies
39
Views
3 Years
Discussion Span
Last Post by JorgeM
0

Do you have any relevant code?

Generally, you can pass values back to your server side code by using HTML input elements of type hidden.

0

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.webaddresshere.com"> <html xmlns="http://www.address/xhtml" lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script varname = 'user' type='text/javascript'>var user={ "name": "username",

Followed by a list of variables and declarations. This is from firebug HTML → Response tab.

I will look up the hidden passing you suggested and see if I can get it to work.

0
<script type="text/javascript">

var locate = "addresshere"

var id = locate.getValue("empid");

</script>  

VarID.set(id)

Am I on the right track? the VarID.set(id) is the application the variable is being passed to setting the javascript variable to something it can use. I don't think it needs to be in the script brackets but I don't know.

Edited by Andrew_13

0

Ok so generally when you want to get some client side value back to your server side scripting, you can do so via an input element through the form submission. there are other ways, but this is common when there is a form involved. Otherwise, you can use ajax to interact with your server side code without having a page postback/refresh.

So lets say you have a form and you want to send some client side variable's value back with the form submission.

Within the form element's opening and closing tags, you would include another input element of type hidden. For example...

<input type="hidden" name="myHidden" value="my-value" />

Now from your server side code, you would access this form element just like you would any other input element that was included in the POST.

Otherwise, you could use javascript on the page and retreive this value and perform some other action such as an ajax request, more processing, etc...

<script>

function someFunction()
{
    var x = document.getElementById("myHidden").value;

    // take this hidden elment value and write it somewhere
    // else on the page...
    document.getElementById("someOtherElement").innerHTML = x;
}

</script>
0

Ah, I see. If I understand your explanation correctly I think I know my issue just not the resolution.

So, the variable I am trying to retrieve for use in the application is not via form but on the server side; it is embedded along with other variables.

I don't have access to editing the javascript on the page where the variable is located but instead in the application I am using I want to use to retrieve the variable, I am trying to write something that calls the variable's locations and retrieves the information to use in the application.

If I misunderstood something, just let me know.

Edited by Andrew_13

0

So, the variable I am trying to retrieve for use in the application is not via form but on the server side; it is embedded along with other variables.

if its a server side variable, you work with this server side. If you need to work with this variable client side, on your server side code, you would create the <input /> element of type hidden and assign the value to this element so you can work with it client side.

I am trying to write something that calls the variable's locations and retrieves the information to use in the application.

So, hard to say without knowing the specifics, but just for your knowledge, if you want to move values between client and server, it can be done as I described above.

The use of hidden elements if very common because you can think of a hidden element as a "placeholder" to store the value during its trip back to the server typically on a form submission.

If you can use or have access to hidden elements, then its fairly easy to move the target value between client and server. if you have access to javascript, you can use other techniques to move the value.

0

So I'm using a application called Lectora, that creates computer based training modules and runs in a LMS (Learning Management System). The information I am trying to retrieve is on embedded in the page code of the LMS and I need to write an external HTML object that runs the javascript to go to that page and retrieve the variable.

So my biggest problem or concern is, can I access the page's information without have access to the code itself. I am using firebug to see the variable but have no control over anything else.

How to I tell the application to go to the page's address and then retrieve the variable? Or are you addressing what I'm asking and its just going over my head?

0

So my biggest problem or concern is, can I access the page's information without have access to the code itself. I

How to I tell the application to go to the page's address and then retrieve the variable?

so if I understand correctly, you are trying to get some information off a page.. If that is the case, what comes to mind is that many of the server side scripting languages web. and desktop/apps have the ability to access a remote web page via the URL. Then using the scripting language, you write code to parse through the collected data (also known as screen scraping) until you find the data of interest. At that point, you have the data and you continue on your merry way and process it accordingly.

Edited by JorgeM

0

Well the information isn't on the page but embedded in the page HTML, but after talking to some others it seems this task is impossible.

Well...this is embarassing!

0

If its in the response when the page is called, you should be able to parse the response and find the data you are looking for unless its random text somewhere on the page.

If it's not written on the page but calculated client side, you would have to retrieve milfoil pieces if info and perform your own calculation.

Edited by JorgeM

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.