View Full Version : Javascript problem in setting URL


gilgalbiblewheel
02-15-2006, 10:22 PM
Javascript problem in setting URL
I'm having difficulty in setting up the URL in by Javascript.
I have:

<script language="JavaScript" type="text/javascript">
<!--
function go1(Keyword,Keywordc,Keywordb,Keywordd,Keyworde,Keywordf,Keywordg,Keywordh)
{
document.getElementById('ifrVerse').src='showversea.asp?id=' + [color=red]document.bookSelect.id1.options[document.bookSelect.id1.selectedIndex].value[/color] + '&keyword=' + Keyword.replace(/[ ]/g,'+') + '&keywordc=' + Keywordc

}
function go2(Keyword,Keywordc,Keywordb,Keywordd,Keyworde,Keywordf,Keywordg,Keywordh)
{
document.getElementById('ifrVerse2').src='showversea.asp?id=' + [color=red]document.bookSelectb.id2.options[document.bookSelectb.id2.selectedIndex].value[/color] + '&keyword=' + Keyword.replace(/[ ]/g,'+') + '&keywordc=' + Keywordc
}

//-->
</script>


This is the URL I get:
/showversea.asp?id=[color=red]8654[/color]&keyword=[color=red]8654[/color]&keywordc=[color=blue]king[/color]

As you see [color=red]8654[/color] is written twice. And [color=blue]king[/color] is bumped over to &keywordc. It should be with &keyword.

I have 2 forms:
<form name="bookSelect" action="showversea.asp" method="get" target="ifrVerse">
<select name="id1" id="id1" size="10" style="width:200;" onchange="go1(document.getElementById('id1').value,'<%=Keyword%>','<%=Keywordc%>');">

and
<form name="bookSelectb" action="showversea.asp" method="get" target="ifrVerse2">
<select name="id2" id="id2" size="10" style="width:200;" onchange="go2(document.getElementById('id2').value,'<%=Keyword%>','<%=Keywordc%>');">


The iFrames I have no problem with but here they are:

<iframe
src ="/wheelofgod/kjvresplistbox.asp"
width="300" height="1200" name="ifrVerse" id="ifrVerse">
</iframe>

</td>
<td>
<iframe
src ="/wheelofgod/kjvresplistbox.asp"
width="300" height="1200" name="ifrVerse2" id="ifrVerse2">
</iframe>

abhishekmat
02-21-2006, 09:10 AM
I am not able to find any problem in your code :)

Just added names for iframe. Add some items under your SELECT and check.

Here it is...

<html>
<title>
DO IT THIS WAY
</title>
<head>
<script language="JavaScript" type="text/javascript">
<!--
function go1(Keyword,Keywordc,Keywordb,Keywordd,Keyworde,Ke ywordf,Keywordg,Keywordh)
{
document.getElementById('ifrVerse').src='showverse a.asp?id=' + document.bookSelect.id1.options[document.bookSelect.id1.selectedIndex].value + '&keyword=' + Keyword.replace(/[ ]/g,'+') + '&keywordc=' + Keywordc
}
function go2(Keyword,Keywordc,Keywordb,Keywordd,Keyworde,Ke ywordf,Keywordg,Keywordh)
{
document.getElementById('ifrVerse2').src='showvers ea.asp?id=' + document.bookSelectb.id2.options[document.bookSelectb.id2.selectedIndex].value + '&keyword=' + Keyword.replace(/[ ]/g,'+') + '&keywordc=' + Keywordc
}

//-->
</script>
</head>
<body>
<form name="bookSelect" action="showversea.asp" method="get" target="ifrVerse">
<select name="id1" id="id1" size="10" style="width:200;" onchange="go1(document.getElementById('id1').value,'<%=Keyword%>','<%=Keywordc%>');">
</form>

<form name="bookSelectb" action="showversea.asp" method="get" target="ifrVerse2">
<select name="id2" id="id2" size="10" style="width:200;" onchange="go2(document.getElementById('id2').value,'<%=Keyword%>','<%=Keywordc%>');">
</form>

<iframe name="ifrVerse"
src ="/wheelofgod/kjvresplistbox.asp"
width="300" height="1200" name="ifrVerse" id="ifrVerse">
</iframe>

<iframe name="ifrVerse2"
src ="/wheelofgod/kjvresplistbox.asp"
width="300" height="1200" name="ifrVerse2" id="ifrVerse2">
</iframe>
</body>
</html>


Let me know ..

Abhishek

gilgalbiblewheel
02-21-2006, 11:06 AM
I did.
<select name="id1" id="id1" size="10" style="width:200;" onchange="go1([COLOR="Red"]<%'identity',%>[/COLOR]'<%=Keyword%>','<%=Keywordc%>');">
After knocking off [COLOR="Red"]<%'identity',%>[/COLOR] everything came to place.
showversea.asp?id=8110&keyword=king&keywordc=for%20ever

<script language="JavaScript" type="text/javascript">
<!--
function go1(Keyword,Keywordc,Keywordb,Keywordd,Keyworde,Keywordf,Keywordg,Keywordh)
{
document.getElementById('ifrVerse').src='showversea.asp?id=' + document.bookSelect.id1.options[document.bookSelect.id1.selectedIndex].value + '&keyword=' + Keyword.replace(/[ ]/g,'+') + '&keywordc=' + Keywordc;
}
function go2(Keyword,Keywordc,Keywordb,Keywordd,Keyworde,Keywordf,Keywordg,Keywordh)
{
document.getElementById('ifrVerse2').src='showversea.asp?id=' + document.bookSelectb.id2.options[document.bookSelectb.id2.selectedIndex].value + '&keyword=' + Keyword.replace(/[ ]/g,'+') + '&keywordc=' + Keywordc;
}

//-->
</script>

yaldex
11-02-2006, 05:40 AM
Looks good - technically.

Did you try saving the values into variables first and then echoing them through a JavaScript alert() to see if they really contain what you expect them to contain?