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> Code (markup): This is the URL I get: /showversea.asp?id=8654&keyword=8654&keywordc=king As you see 8654 is written twice. And king 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%>');"> Code (markup): 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%>');"> Code (markup): 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> Code (markup):
1) Part of the problem with your sample is that it's missing some preliminary output before the final output. What I'd suggest you do to debug it is use Response.Write (variable name) for your ASP code and alert (variable name) for your Javascript at various spots to compare the actual output with what you were expecting to get. My suspicion is that the error isn't in the Javascript itself, but in the passing of parameters to it. One that I can see right off the top is the passing of the first parameter. document.getElementById('id2').value Code (markup): id2 is a select box. So as a result, you have to find the value of the selected option within the select box. Something like this: document.getElementById('id2').options[document.getElementById('id2').selectedIndex].value Code (markup): This should work. And then from there, pass your parameters. 2) One other thing that I noticed is that your keyword is your second parameter being passed to the Javascript, but it's the first one being retrieved. I used color coding to show you exactly what's being passed to what. i.e. <select name="id2" id="id2" size="10" style="width:200;" onchange="go2([color=red]document.getElementById('id2').value[/color],'[color=blue]<%=Keyword%>[/color]','<%=Keywordc%>');"> Code (markup): Gets passed to function go2([color=red]Keyword[/color],[color=blue]Keywordc[/color],Keywordb,Keywordd,Keyworde,Keywordf,Keywordg,Keywordh) Code (markup): That's probably your problem. If not, try the other stuff I mentioned. If it works...try the other stuff I mentioned for debugging anyway. It saves a buttload of time.
I tried both. I know the 2nd problem is true. Adding identity didn't help: <script language="JavaScript" type="text/javascript"> <!-- function go1([COLOR=red]identity[/COLOR],Keyword,Keywordc) { document.getElementById('ifrVerse').src='showversea.asp?id=' + document.bookSelect.id1.options[document.bookSelect.id1.selectedIndex].value + '&keyword=' + Keyword.replace(/[ ]/g,'+') + '&keywordc=' + Keywordc } function go2([COLOR=red]identity[/COLOR],Keyword,Keywordc) { document.getElementById('ifrVerse2').src='showversea.asp?id=' + document.bookSelectb.id2.options[document.bookSelectb.id2.selectedIndex].value + '&keyword=' + Keyword.replace(/[ ]/g,'+') + '&keywordc=' + Keywordc } //--> </script> Code (markup): and <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').options[document.getElementById('id1').selectedIndex].value,'[COLOR=red]identity[/COLOR]','king','for ever');"> <option value="7499">1 Samuel 13:13</option> Code (markup): Adding identity didn't help: <script language="JavaScript" type="text/javascript"> <!-- function go1([COLOR=red]identity[/COLOR],Keyword,Keywordc) { document.getElementById('ifrVerse').src='showversea.asp?id=' + document.bookSelect.id1.options[document.bookSelect.id1.selectedIndex].value + '&keyword=' + Keyword.replace(/[ ]/g,'+') + '&keywordc=' + Keywordc } function go2([COLOR=red]identity[/COLOR],Keyword,Keywordc) { document.getElementById('ifrVerse2').src='showversea.asp?id=' + document.bookSelectb.id2.options[document.bookSelectb.id2.selectedIndex].value + '&keyword=' + Keyword.replace(/[ ]/g,'+') + '&keywordc=' + Keywordc } //--> </script> Code (markup): <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').options[document.getElementById('id1').selectedIndex].value,'[COLOR=red]identity[/COLOR]','king','for ever');"> <option value="7499">1 Samuel 13:13</option> Code (markup): Also the URL: showversea.asp?id=8194&keyword=identity&keywordc=king if I eliminate identity then it doubles the id (8194) and leaves king to keywordc.
That's because you're adding a parameter before identity when you pass it: <select name="id1" id="id1" size="10" style="width:200;" onchange="go1([color=red]document.getElementById('id1').options[document.getElementById('id1').selectedIndex].value[/color],'identity','king','for ever');"> Code (markup): This should be: <select name="id1" id="id1" size="10" style="width:200;" onchange="go1('identity','king','for ever');"> Code (markup): It's not what you're adding that's causing the problem. It's what you're not removing that is.
gilgalbiblewheel, if you're going to post your question in more than one forum, then try to pay attention to them all. Looks like AWD1 has given you all the answers you need. I not sure why you're still confused about this.
The reason I post in multiple forums is to get a fast answer. It happens to be that some take days to answer. Thanks AWD1. Your answer wasn't far away: <select name="id1" id="id1" size="10" style="width:200;" onchange="go1([B][COLOR="Red"]<%'identity',%>[/COLOR][/B]'<%=Keyword%>','<%=Keywordc%>');"> Code (markup): After knocking off <%'identity',%> 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> Code (markup):