i have a problem when using prompts

I have the following propmt and when an appostrofy is used then it wont insert the text into a website as it should.

Help!!


	set titleText to getCaptions()
	tell application "Internet Explorer" to do script "window.document.forms[0].elements[2].value='" & titleText & "'"
	delay 1.0
	activate


---------
on getCaptions()
	set promptText to "What would you like the title to be"
	set titlePrompt to (display dialog promptText default answer "Insert Title" with icon 1)
	set theTitle to text returned of titlePrompt
	set titleText to theTitle 
	return titleText
end getCaptions


You must escape the single-quote, or let “quoted form” to do the job for your:

tell application "Internet Explorer" to do script "window.document.forms[0].elements[2].value=" & quoted form of titleText

jj the code doesnt work. I copied what you posted and replaced it with my IE part.

What else do you think i should try?

Cheers Guys

Ouch!

Then you must do it “manually”. Eg:

set titleText to "let's go!" --> sample text with an apostrophe
set AppleScript's text item delimiters to "'"
set titleText to titleText's text items
set AppleScript's text item delimiters to "\'"
set titleText to "'" & titleText & "'" --> 'let's go'
set AppleScript's text item delimiters to {""}
tell application "Internet Explorer" to do script "window.document.forms[0].elements[2].value=" & titleText

Cheers thanks alot it works.

Seems abit long. Oh well. Applescript woes keep getting bigger