-
Pop-up with variable contents problem??
OK, what I am trying to accomplish is to have a form that my users fill out, and html code is generated for them. To reach this goal, I have created a series of input text boxes that are named. After the user has entered something into them, the contents of these are then taken and surrounded by pre-written html code (Such as putting a title in formated table and so on...) on the puch of a button, which is then displayed as text in another seperate input text box so the user can cut and paste the code to what they need it for. This all works just fine and dandy... The code apears where it is supposed to and is formated as written.
The problem is coming into play when I try and get this data to be displayed within a 'preview' type window. I want the user to be able to see what they have created before cutting and pasting in order to make any needed changes. So, what I was trying to accomplish is to get flash to create a pop-up window and then write the contents of the end text box to that page. To do this I came up with this:
Code:
on (press) {
thecode="Javascript:NewWindow=window.open('thecode','newWin','width=650,height=600,left=50,top=50,toolbar=No,location=No,scrollbars=Yes,status=No,resizable=No,fullscreen=No'); NewWindow.document.write(\<HTML><HEAD><TITLE>Preview Window</TITLE></HEAD><BODY BGCOLOR=#" + bgcolor + "><br>" + html + "<br></BODY></HTML>\)";
getURL(thecode);
}
(Just FYI: "thecode" statement is all on one line, and '+ bgcolor +' & '+ html +' are input text boxes within the movie: the html one is the box that contains all of the code to be displayed...)
Now I know that this isn't going to work because it is going to look for a page in the same directory called 'thecode'. Unfortunatly though, I can't seem to figure out how to get it to read the correct thing... This is just where I started this morning and was planning on working off of. At one point, I was able to get it to show the contents of the html box by removing the popup code and going to just a _blank window; this didn't seem to work right everytime though, and also would only display the contents of the html box if they were very short; if I added any length to them what so ever, I would get what I am getting right now: Nothing! Not even a javascript error in my browser...
Anybody have any suggestions...
"After I'm dead I'd rather have people ask why I have no monument than why I have one."
- Cato the Elder (234-149 BC, AKA Marcus Porcius Cato)
http://www.DSMMG.com
DS@DSMMG.com
-
Hi,
creating a new window with your content from javascript is
win = window.open('', 'name', 'width=400,...');
win.document.write('<HTML>....</HTML>');
win.document.close()
Now, doing the same thing from flash you would use the normal
geturl("javascript:code here")
method. Unfortunately there are two problems:
since the code uses both single and double quotes already, you will have to make sure that quotes inside your text are properly escaped.
Using the complete string as a variable seems to avoid the double quotes problem... having to escape single quotes is annoying enough...
Even worse, some browsers allow a line return inside the text as %0a, while others interpret it when reading the js and complain about unmatched quotes.
There may also be issues with other special characters.
If this ever becomes a problem, consider encoding the text inside flash and decoding it with a javascript function that would be part of the html page embedding your movie
Musicman
Last edited by Musicman; 01-03-2003 at 05:23 PM.
-
Thanks for the reply... But I still need a little bit of help if you don't mind.
All right, I got it opening a window and writing to it, but I seem to be having a problem with anything of any length being written to it. Here's what is seeming to work part time:
Code:
on (press) {
thecode = "Javascript:Win=window.open('\','Win','width=650,height=600,left=50,top=50,toolbar=No,location=No,scrollbars=Yes,status=No,resizable=No,fullscreen=No'); var html=html; Win.document.write(\"<HTML><HEAD><TITLE>Preview Window</TITLE></HEAD><BODY><br>" + html + "<br></BODY></HTML>\")"
getURL(thecode);
}
Again, the var. 'thecode' is one line long. The problem that I am having is, as i said, when I write anything of any length to it, nothing happens. It's like the button was never pressed. Any ideas on what this might be all about?
Also, if you could add a little bit of detail about encoding the text in the flash movie and then decoding it with js, I would really appreciate it. I'm not quite sure how one would do this...
Thanks agian...
Oh yea, and here's an example of what does not work when written to it:
Code:
<table width='600' border='1' cellspacing='0' cellpadding='5' bgcolor=#CCCCCC bordercolor=#000000 align='center'><tr><td><table width='590' border='1' cellspacing='0' cellpadding='5' bgcolor=#FFFFFF bordercolor=#000000><tr><td colspan='2'><div align='center'><font face='Arial, Helvetica, sans-serif' color=#000000 size='4'><b>One</b></font></div></td></tr><tr><td width='200'><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'><b>Manufacturer:</b></font></td><td width='390'><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'>Two</font></td></tr><tr><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'><b>Model:</b></font></td><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'>Three</font></td></tr><tr><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'><b>Year of Manufacture:</b></font></td><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'>Four</font></td></tr><tr><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'><b>Number of Units/Colors: </b> </font></td><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'>Five</font></td></tr><tr><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'><b>Number of Impressions (millions):</b></font></td><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'>Six</font></td></tr><tr><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'><b>Sheet Size:</b></font></td><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'>Seven</font></td></tr><tr><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'><b>Serial Number:</b></font></td><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'>Eight</font></td></tr><tr><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'><b>Additional Information & Equipment Details:</b></font></td><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'>Nine</font></td></tr><tr><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'><b>Equipment Condition:</b></font></td><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'>Ten</font></td></tr><tr><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'><b>Seller's Reference Number:</b></font></td><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'>Eleven</font></td></tr><tr><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'><b>Terms on which Offered: </b></font></td><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'>Twelve</font></td></tr><tr><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'><b>Date Available:</b></font></td><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'>Thirteen</font></td></tr><tr><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'><b>Can it be seen in Operation:</b></font></td><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'>Fourteen</font></td></tr><tr><td><font face='Arial, Helvetica, sans-serif'color=#000000 size='2'><b>Seller's profile:</b></font></td><td><font face='Arial, Helvetica, sans-serif' color=#000000 size='2'>Fifteen</font></td></tr></table></td></tr></table>
All of this is one line with no return breaks or anything...
On th e flip side, something simple like this will work:
Code:
font face=<'Arial, Helvetica, sans-serif' color=#000000 size='2'><b> The man with the green ham ran up the blue hill... </b></font>
I don't have any idea why this would be the case, but thought that it might shed some light on the situation...
Thanks, DS
Last edited by dsmmg; 01-04-2003 at 04:52 PM.
"After I'm dead I'd rather have people ask why I have no monument than why I have one."
- Cato the Elder (234-149 BC, AKA Marcus Porcius Cato)
http://www.DSMMG.com
DS@DSMMG.com
-
Hi,
I have written some code to cope with flash-hostile formmail scripts - this puts variables into a html form and submits it. I just tried with F6 and mozilla - it was still working with 1800 characters message; F5 gave up much earlier with a "computer running slow" on the conversion. Now your data seems to be still longer; also I do not know whether maximum lengths would differ between browsers.
You will find that code at www.fontimages.org.uk - it is used similar to your situation. If it really exceeds a max size, I would probably use multiple geturl calls to copy over the variable in slices of, say, 1000 chars each, and a final call to actually create and fill the window.
Musicman
-
All right... Thanks for the thoughts.. I'm slowly but surely getting there!!
What I have done now is to take the variables, all 22 of them, and instead of writing them to a document, I used your code to write them to fields in the html page, as is suggested. I then set it up with the additional characters and information to be passed in the write.doc part to be in the html page, not the flash movie. So the only thing that Flash is sending is the answers to the questions (the input text boxes within the flash movie)to the page itself, and your code to remove the returns is working just fine. The user would then click on a traditional button on the page to preview the document.
The problem that I am having now is that, agian, when there is any amount of text sent, nothing is sent. It apears that the amount causing the problem is also very low; like somewhere in the 200 to 250 character range. So, I tried to break the sending of the variable info into several differnet getURL functions: I just couldn't get that to work... First, I tried to do it with sets of 2 variables with thier own getURL still using the sendit javascript. That did nothing. Then I tried to seperate them out in both the movie and the page (IE sedit1, sendit2, sendit3) by breaking the script into smaller parts. The best that I could do with that was to get the very last sendit (sendit11!!!) to work correctly...
Is there any other way to break this down? All I'm sending now are the answers to the questions in one geturl function; this is only working with small amounts of data. How would you break it down? Just FYI, I am publishing in F5...
If you, or anyone wants to take a look and see what I am doing with this, and how far I have gotten, just gotohttp://www.dsmmg.com/test/pressholder2.html . This is where the movie is sending it as one geturl and it is writing to the html page. I have made the fields visible to see when and if it writes to them, and included a character counter on the html page as well.
Thanks agian for all of your help... I probably would have given up well before now if it weren't for the great help you've been providing!
DS
"After I'm dead I'd rather have people ask why I have no monument than why I have one."
- Cato the Elder (234-149 BC, AKA Marcus Porcius Cato)
http://www.DSMMG.com
DS@DSMMG.com
-
Hi,
I tried my email thingy again, with N4.78 and player 5, and got to about 900 characters total before the player got "too slow"
Now, even if you use F5 to create your movie, you can still ask people to use player 6, if that makes problems smaller.
Now, in order to break up things, I could imagine
geturl("javascript:sendQ1(....)")
with a corresponding function sendQ1 that just fills the Q1 form var, and so on.
I believe, that a short delay between geturl calls would be helpful.
Musicman
-
Thanks agian...
Ok, now I have no idea what I am doing wrong here... It seems as though this should work perfectly. What I have is this:
Actionscript on the button:
Code:
on (release) {
getURL('javascript:sendMAINBGCOLOR("'+myescape(MAINBGCOLOR)+'"); void(0)');
}
corresponding function in html:
Code:
function sendMAINBGCOLOR(MAINBGCOLOR)
{ document.forms.copy.MAINBGCOLOR.value = myunescape(MAINBGCOLOR);
return false;
}
I have this for each of the 22 variables: which says to me that each geturl call should function correctly and independently of each other and all should function. That's not what is happening though.
Instead of each one working individually, only the very last of the bunch is writing to the correct variable in the form. I don't get it!! What am I doing wrong? Does it have something to do with the 'return false' portion? Or the void(0) in the AS? If it isn't painfully obvious by now, I'm really not that knowledegable with javascript... Sorry if I sound like a helpless dummy; I'm trying to plod through this as best I can. Agian, thanks MusicMan for all of your help.
DS
"After I'm dead I'd rather have people ask why I have no monument than why I have one."
- Cato the Elder (234-149 BC, AKA Marcus Porcius Cato)
http://www.DSMMG.com
DS@DSMMG.com
-
Musicman,
Got your mail... Thanks for all of your help with this!!! Here's the link to the latest version of the file:
http://www.dsmmg.com/test/online.html
To functions in the swf are on the create html code button (Under the bottom text box...): When that is clicked the code is written to the text box, and the boxes at the bottom of the screen are in the html to be written to...
I'll send this to you in a mail as well... Thanks agian...
DS
Edited NOTE: The URL above had a typo in it that I just corrected: Should have read '/test/', but instead read '/text/'. It's fixed now in case anyone wants to check it out... Sorry bout that!!
DS
Last edited by dsmmg; 01-08-2003 at 03:12 PM.
"After I'm dead I'd rather have people ask why I have no monument than why I have one."
- Cato the Elder (234-149 BC, AKA Marcus Porcius Cato)
http://www.DSMMG.com
DS@DSMMG.com
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|