עבור לתוכן

עזרה עם JS וטופס

Featured Replies

פורסם

יש לי בעיה עם JS וטופס אשמח אם מישהו יעזור לי:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[url]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/url]
<html xmlns="[url]http://www.w3.org/1999/xhtml">[/url]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255" />
<title>Untitled Document</title>
</head>

<body>

<script language="javascript">
<!--
function loc(loca) {
document.write("X");
var chr = split(loca);

for (i=0;i<chr.length;i++) {
if (chr[i]=="p" && chr[i+1] == "r") {
chr[i] = "l";
chr[++i] = "2";
break;
}
}

window.location.href=chr;

}
//-->
</script>


<form OnSumbit = 'loc(window.location);' action="">
<label>
<input type="submit" name="Submit" value="הבא"/>
</label>
</form>


</body>
</html>

בתודה מראש

פורסם

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1255" />

<title>Untitled Document</title>

</head>

<body>

<script language="javascript">

function loc(loca) {

document.write("X");

var chr = split(loca);

for (i=0;i<chr.length;i++) {

if (chr=="p" && chr[i+1] == "r") {

chr = "l";

chr[++i] = "2";

break;

}

}

window.location.href=chr;

}

</script>

<input type="submit" name="Submit" value="הבא" onclick='loc(window.location);'/>

</body>

</html>

פורסם
  • מחבר

כבר התקדמות אך משום מה FF כותב לי ב-JS CONSOLSE:

Error: [JavaScript Error: "split is not defined" line: 11]

פורסם

אולי התכוונת לכתוב אז

loca.split() instead of what you wrote.. it's good to learn the basics of a language before using it

פורסם
  • מחבר

עשיתי ככה ועדיין לא עובד: :-\

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[url]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/url]
<html xmlns="[url]http://www.w3.org/1999/xhtml">[/url]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255" />
<title>Untitled Document</title>
</head>

<body>

<script language="javascript">
function loc(loca) {

var chr = loca.split;

for (i=0;i<chr.length;i++) {
if (chr[i]=="p" && chr[i+1]=="r") {
chr[i] = "l";
chr[++i] = "2";
break;
}
}

window.location = chr;

}
</script>

<input type="submit" name="Submit" value="הבא" onclick='loc(window.location);'/>
</body>
</html>

FF כותב "chr has no properties".

פורסם

take a closer look... i said loca.split() which is a method, you decided to write loca.split which is a datamember/property (which ofcourse doesnt exist)

פורסם
  • מחבר

ניסיתי:

!

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[url]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/url]
<html xmlns="[url]http://www.w3.org/1999/xhtml">[/url]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255" />
<title>Untitled Document</title>
</head>

<body>

<script language="javascript">
function loc(loca) {

var chr = loca.split();

for (i=0;i<chr.length;i++) {
if (chr[i]=="p" && chr[i+1]=="r") {
chr[i] = "l";
chr[++i] = "2";
break;
}
}

window.location = chr;
}
</script>

<input type="submit" name="Submit" value="הבא" onclick='loc(window.location);'/>
</body>
</html>

FF כעת אומר:

"loca.split is not a functin".

פורסם

אז נסה

loca.toString().split() and that should work

פורסם
  • מחבר

מוזר זה לא עובד לי אלא רק loca.toString... :P

עכשיו דבר מוזר עוד יותר שקורה לי הוא ככה:

  function loc(loca) {

var chr = loca.toString();

for (i=0;i<45;i++) {
if (chr[i]=="p" && chr[i+1]=="r") {
alert("H");
chr[i] = "1";
chr[i+1] = "2";
break;
}
}

document.write(chr);
}

ההודעה h נכתבת אבל המחרוזת לא משתנה. :pissed:

פורסם

split עובד, אבל זה רק בתנאי שיש לך מושג מה הוא עושה ומה הפרמטרים שלו....

בלי לבדוק, אני יכול להניח שזה לא עובד כי אתה עושה משהו כמו i מ 0 עד 45 במקום i מ 0 עד chr.length פחות 2 (כשאתה ניגש לתא במערך שלא קיים, ה JS יזרוק EXCEPTION ויפסיק נראה לי.

פורסם
  • מחבר

לא עובד: בכלל:

<script language="javascript">
function loc(loca) {

var chr = loca.toString().split();

for (i=0;i<chr.length;i++) {
if (chr[i]=="p" && chr[i+1]=="r") {
alert("H");
chr[i] = "1";
chr[i+1] = "2";
break;
}
}

document.write(chr);
}
</script>

רק מדפיס את הכתובת הנוכחית:

<script language="javascript">
function loc(loca) {

var chr = loca.toString().split();

for (i=0;i<chr.length;i++) {
if (chr[i]=="p" && chr[i+1]=="r") {
alert("H");
chr[i] = "1";
chr[i+1] = "2";
break;
}
}

document.write(chr);
}
</script>

פורסם

יש לי רעיון מ-ע-ו-ל-ה, תסביר בדיוק מה אתה צריך !

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים