/    Sign up×
Community /Pin to ProfileBookmark

retrieving data

I am creating a WYSIWYG editor which is created in a separate javascript file. I want to get the html it produces. I know what variable it is in, however; being in a separate file, and inside a function in that file, I am not sure how to get the value of this variable in the html file I am display everything to the user in.

please help, thank you!

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@mgrenierauthorFeb 09.2005 — sorry if that wasn't clear. I need to retrieve a variable from the .js file and display them in my html file.
Copy linkTweet thisAlerts:
@Warren86Feb 09.2005 — By "display them," I have assumed that no form is involved. So, try the following, note that the variable in the .js file is "global," meaning it is declared OUTSIDE of the function.

--------- Main document -----------

<HTML>

<Head>

<Script Language=JavaScript Src='Test.js'></Script>

<Script Language=JavaScript>

function dispVar(){

setText();
document.getElementById('isText').innerHTML = anyName;
}


</Script>

</Head>

<Body>

<Div id='isText'></Div>

<br><br>

<input type=button value="Display Variable Text" onclick="dispVar()">

</Body>

</HTML>

----------- Test.js --------------

var anyName = "";

function setText(){

anyName = "This is some text"
}
Copy linkTweet thisAlerts:
@mgrenierauthorFeb 09.2005 — would it be any different if there is a form?
Copy linkTweet thisAlerts:
@Warren86Feb 09.2005 — Yes, if you need the text displayed in a textbox, which is within a form.
Copy linkTweet thisAlerts:
@mgrenierauthorFeb 09.2005 — yes there must be a form, I'll give you the code I have it might help. What I need is a form to display this WYSIWYG editor in, then I must be able to access the variable where the submitted text is stored. For now I just want to display it on the page while I am working on this and dubugging it but eventually I want to store the variable contents in a DB. here is my code so far:

html>

<head>

<title>Rich Text Editor</title>

<script type="text/javascript" src="WYSIWYG-Editor/browserdetect.js"></script>

<script type="text/javascript" src="WYSIWYG-Editor/editor.js"></script>

</head>

<body>

<form onsubmit="editor1.prepareSubmit()" method="post">

<script type="text/javascript">

var editor1 = new WYSIWYG_Editor('editor1');

editor1.display();

</script>

<input type=submit id=submit name=submit><br>

<script type="text/javascript">

//here I would like to display a variable from editor.js

</script>

</form>

</body>

</html>
Copy linkTweet thisAlerts:
@Warren86Feb 09.2005 — That's just not going to happen, using a form and submitting it. I have a differnt approach. I have nothing further to offer, and am unsubscribing from this thread.

-------- Main document ---------------

<HTML>

<Head>

<Script Language=JavaScript>

xferWindow = "";
tmpVal = "";

function xferHTML(){

xferWindow.document.getElementById('xferArea').value = tmpVal;
}

function getHTML(){

tmpVal = isHTML.innerHTML;
xferWindow = window.open('EditWindow.html','EditWin','toolbar=0,status=0,height=450,width=360,top=40,left=50');
xferWindow.opener = self;
}


</Script>

</Head>

<Body>

<Div id='isHTML'>

<center>

<h3>This a Headline</h3>

<textarea cols="20" rows="2">This is a sample text area</textarea>

<input type=button value="Demo Button">

<p>This is some text </p>

<img src='anyImage.jpg'>

</center>

</Div>

<hr>

<center>

<input type='button' value='Show HTML in Edit Window' onClick="getHTML()">

</center>

</body>

</html>

---------- EditWindow.html ------------

<HTML>

<Head>

<Title>Your Title Here</Title>

<Script Language=JavaScript>

function saveIt(){

opener.document.getElementById('isHTML').innerHTML = xferArea.value;
}


</Script>

</Head>

<Body>

<textarea cols="40" rows="23" id="xferArea">

</textarea>

<Script Language=JavaScript>

opener.xferHTML();

</Script>

<input type=button value="Save Changes" onclick="saveIt()">

</Body>

</HTML>
Copy linkTweet thisAlerts:
@mgrenierauthorFeb 09.2005 — i dont really understand what your script is doing. I pretty new to javascript
×

Success!

Help @mgrenier spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.23,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...