How do I add keyword to the javascripted url?

Discussion in 'JavaScript' started by gilgalbiblewheel, Jan 5, 2006.

  1. #1
    How do I add keyword to the javascripted url?
    It's for the onchange and the iFrame. Once the dropdown is selected then the iFrame would show the verse.
    I have an old code that looked like this:
    location = "kjvresplistboxshowversea.id.options[document.myForm.id.selectedIndex].value + "&Keyword=" + document.myForm.Keyword.value + "&Keywordb=" + document.myForm.Keywordb.value + "&Keywordc=" + document.myForm.Keywordc.value + "&Keywordd=" + document.myForm.Keywordd.value + "&Keyworde=" + document.myForm.Keyworde.value + "&Keywordf=" + document.myForm.Keywordf.value + "#bcv
    Code (markup):
    	<script language="JavaScript" type="text/javascript">
    	<!--
    		function go1()
    		{
    		booksa.action = "showversea.asp?id=";
    		booksa.submit();
    		}
    	//-->
    	</script>
    	
    		<form name="booksa" action="showversea.asp" method="get" target="ifrVerse">
    		<select name="id" size="10" style="width:200;" onchange="go1();">
    			
    				<option  value="5276">Deuteronomy&nbsp;13:3</option>
    				
    				<option  value="8319">2 Samuel&nbsp;13:1</option>
    
    				
    				<option  value="8322">2 Samuel&nbsp;13:4</option>
    				
    				<option  value="8333">2 Samuel&nbsp;13:15</option>
    				
    				<option  value="12698">Nehemiah&nbsp;13:26</option>
    				
    				<option  value="16341">Psalms&nbsp;145:20</option>
    				
    				<option  value="16772">Proverbs&nbsp;13:24</option>
    
    				
    				<option  value="18774">Isaiah&nbsp;57:8</option>
    				
    				<option  value="26632">John&nbsp;13:1</option>
    				
    				<option  value="26654">John&nbsp;13:23</option>
    				
    				<option  value="26665">John&nbsp;13:34</option>
    				
    				<option  value="26666">John&nbsp;13:35</option>
    
    				
    				<option  value="28275">Romans&nbsp;13:8</option>
    				
    				<option  value="28276">Romans&nbsp;13:9</option>
    				
    				<option  value="28277">Romans&nbsp;13:10</option>
    				
    				<option  value="29055">2 Corinthians&nbsp;13:11</option>
    				
    				<option  value="29058">2 Corinthians&nbsp;13:14</option>
    
    				
    				<option  value="30243">Hebrews&nbsp;13:1</option>
    				
    		</select>
    Code (markup):

     
    gilgalbiblewheel, Jan 5, 2006 IP
  2. cytech

    cytech Guest

    Messages:
    62
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hey, Actually you do not need a javascript.

    If you are just looking to pass the ID number to the iframe what you have will work. Simply pull the "id" from the ASP script.

    If you submitted the form you gave above the form will pass: showversea.asp?id=NUMBER
     
    cytech, Jan 6, 2006 IP
  3. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #3
    The reason I want to add the keyword &keyword= is because showversea.asp has highlighting coding on the keyword. I want the searched keyword highlighted. I'm not asking for an highlighting code. I just want to know how to place through javascript in the url.
     
    gilgalbiblewheel, Jan 6, 2006 IP
  4. cytech

    cytech Guest

    Messages:
    62
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ah I see. :)

    Were are you keywords being pulled? I do not see them in the code posted.

    Are they pulled from a second field?
     
    cytech, Jan 6, 2006 IP
  5. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #5
    Keyword comes from kjv.asp. It also appears in the response page kjvresp.asp (in the url):

    kjv.asp
    |
    |
    kjvresp.asp--iFrame kjvresplistbox.asp--iFrame showversea.asp

    The &keyword= must appear in the showversea.asp's url.

    The reason I want to add the keyword &keyword= is because showversea.asp has highlighting coding on the keyword. I want the searched keyword highlighted. I'm not asking for an highlighting code. I just want to know how to place through javascript in the url.

    The keyword already appears in the kjvresp.asp's url.

    Here's what I'm talking about:
    http://i.domaindlx.com/wheelofgod/kingjames.asp
     
    gilgalbiblewheel, Jan 6, 2006 IP
  6. cytech

    cytech Guest

    Messages:
    62
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I see, first I like the way you have the site setup easy to see the verses.

    well look at your code you did:

    
    booksb.action = "showversea.asp?id=&Keyword=Abraham";
    
    Code (markup):
    So you did it pretty much how it should be.

    Instead of writing the "keyword" direct into the URL place it into a variable

    
    var jsKeyword=<%Keyword%>;
    var bookid=document.FORMNAME.id.seletedIndex;
    var id=document.FORMNAME.id.options[bookid].value;
    books.action="showversea.asp?id="+id+"&Keyword="+jsKeyword;
    
    Code (markup):
    Not sure if it will work, but atleast I know the idea is sound Its what I use when I combine php/asp with Javascript. :)
     
    cytech, Jan 6, 2006 IP
  7. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #7
    I had come up with this before I read your suggestion. (But I tried it and I got the same result below).
    
    	keyword='brutish'
            function go1(identity,keyword)
            {
    document.forms['bookSelect'].action = 'showversea.asp?id=' + identity + '&keyword=\''  + keyword + '\''
               //bookSelect.action = 'showversea.asp?id=' + identity + '&keyword=' + keyword;
               alert(bookSelect.action);
               //bookSelect.submit();
            }
    
    Code (markup):
    The alert says:
    http://127.0.0.1/wheelofgod/showversea.asp?id=[color=red]identity[/color]&keyword=[color=red]keyword[/color]
    Code (markup):
    How can I make identity = the value of the option in the select dropdown?

    And secondly, how can I make
    keyword = <%=Keyword%> ?

    
    			<form name="bookSelect" action="showversea.asp" method="get" target="ifrVerse">
    			<select name="id" size="10" style="width:200;" onchange="go1('identity','keyword');">
    
    Code (markup):
     
    gilgalbiblewheel, Jan 20, 2006 IP
  8. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #8
    Ok Let me redirect my goal.
    I have set an alert. It says:
    
    
    http://127.0.0.1/showversea.asp?id=15418&keyword=brutish
    
    
    Code (markup):
    But when the iFrame opens it writes only this in the URL.

     
    
    http://127.0.0.1/wheelofgod/showversea.asp?id=15418
    
    
    Code (markup):
    The second URL shows what the select name "id" is picking up "15418" from the option value. But it fails to pick up the "keyword" <%=Keyword%>. The page of dropdown is ASP-generated, in other words the ASP builds the dropdown from the result of the database table. Here is the section of the source:
    	<script language="JavaScript" type="text/javascript">
    	<!--
    	function go1(identity,keyword)
            {
    document.forms['bookSelect'].action = 'showversea.asp?id=' + identity + '&keyword='  + keyword 
                   alert(bookSelect.action);
              bookSelect.submit();
            }
    	//-->
    	</script>
    Code (markup):
    And
    		
    <form name="bookSelect" action="showversea.asp" method="get" target="ifrVerse">
    <select name="id" size="10" style="width:200;" onchange="go1(document.forms['bookSelect'].id[document.forms['bookSelect'].id.selectedIndex].value,'brutish');">
    
    
    			
    				<option  value="14659">Psalms&nbsp;49:10</option>
    				
    				[COLOR=Red]<option  value="[B]15418[/B]">Psalms&nbsp;92:6</option>[/COLOR]
    				
    				<option  value="15440">Psalms&nbsp;94:8</option>
    				
    				<option  value="16721">Proverbs&nbsp;12:1</option>
    				
    				<option  value="17254">Proverbs&nbsp;30:2</option>
    				
    				<option  value="18016">Isaiah&nbsp;19:11</option>
    				
    				<option  value="19210">Jeremiah&nbsp;10:8</option>
    
    				
    				<option  value="19216">Jeremiah&nbsp;10:14</option>
    				
    				<option  value="19223">Jeremiah&nbsp;10:21</option>
    				
    				<option  value="20230">Jeremiah&nbsp;51:17</option>
    				
    				<option  value="20976">Ezekiel&nbsp;21:31</option>
    				
    		</select>
    
    
    Code (markup):
     
    gilgalbiblewheel, Jan 20, 2006 IP