Forum Moderators: open

Message Too Old, No Replies

JavaScript forms on Mac and PC

Posting to a page with Javascript forms

         

TriadJustin

3:41 pm on Nov 17, 2003 (gmt 0)

10+ Year Member



Im having a problem with a form using javascript. This form is on a page that allows the end user to click a button ontop of a text box and insert the desired html code around the text highlighted. For instance: <b>adf</b> if you hit the bold button on top. This code works fine on a PC but does not work on a Mac. If you hit the button on a mac nothing happens. Does anyone have any suggestions?

DrDoc

3:53 pm on Nov 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to Webmaster World!

There are some Java applets that do a much better job at this. It will be really hard for you to make it work (using JavaScript) across several browsers/platforms.

TriadJustin

4:01 pm on Nov 17, 2003 (gmt 0)

10+ Year Member



Unfortunately I dont have much of a choice. Im an intern and they request that it be done within Javascript. If I gave you the code for the .js do you think that would help?

DrDoc

4:48 pm on Nov 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do they require cross browser compatibility?

TriadJustin

5:01 pm on Nov 17, 2003 (gmt 0)

10+ Year Member



NO, both can be IE but one for a Mac and the other for a PC.
__________________________________________________________
Here is the code:
function extract()
{
filename=new String();
newname=new String();
var str="";
filename=document.formedit.filebox.value;
for(i=filename.length-1;i>=0;i--)
{
if(filename.charAt(i)!="\\")
str=str + filename.charAt(i);
else
break;
}
newname=str;
str=""
for(i=newname.length;i>=0;i--)
str=str+newname.charAt(i);
document.formedit.file_name.value=str;
}
function insert_link2(my_link2) {
var str = document.selection.createRange().text;
document.formedit.content.focus();
var my_link = prompt("Enter Description:","Click here to...");
if (my_link2!= null) {
var sel = document.selection.createRange();
sel.text = "<a target=_blank href=\"/admin/files/files/" + my_link2 + "\">" + my_link + "</a>";
}
return;
}
function extract2()
{
filename=new String();
newname=new String();
var str="";
filename=document.formedit2.filebox.value;
for(i=filename.length-1;i>=0;i--)
{
if(filename.charAt(i)!="\\")
str=str + filename.charAt(i);
else
break;
}
newname=str;
str=""
for(i=newname.length;i>=0;i--)
str=str+newname.charAt(i);
document.formedit2.file_name.value=str;
}
function ConfirmDelete(id) {
value=confirm("Are you sure?")
if(value)
{
location="delete.cfm?id="+id;
}
}
function format_sel(v) {
var str = document.selection.createRange().text;
document.formedit.content.focus();
var sel = document.selection.createRange();
sel.text = "<" + v + ">" + str + "</" + v + ">";
return;
}
function format_sel2(v) {
var str = document.selection.createRange().text;
document.formedit.content.focus();
var sel = document.selection.createRange();
sel.text = str + "<" + v + ">";
return;
}
function insert_link() {
var str = document.selection.createRange().text;
document.formedit.content.focus();
var my_link = prompt("Enter URL:","http://");
if (my_link!= null) {
var sel = document.selection.createRange();
sel.text = "<a href=\"" + my_link + "\">" + str + "</a>";
}
return;
}
function format_selb(v) {
var str = document.selection.createRange().text;
document.formedit2.content.focus();
var sel = document.selection.createRange();
sel.text = "<" + v + ">" + str + "</" + v + ">";
return;
}
function format_sel2b(v) {
var str = document.selection.createRange().text;
document.formedit2.content.focus();
var sel = document.selection.createRange();
sel.text = str + "<" + v + ">";
return;
}
function insert_linkb() {
var str = document.selection.createRange().text;
document.formedit2.content.focus();
var my_link = prompt("Enter URL:","http://");
if (my_link!= null) {
var sel = document.selection.createRange();
sel.text = "<a href=\"" + my_link + "\">" + str + "</a>";
}
return;
}
function mouseover(el) {
el.className = "raised";
}
function mouseout(el) {
el.className = "button";
}
function mousedown(el) {
el.className = "pressed";
}
function mouseup(el) {
el.className = "raised";
}
//-->
</script>