Url string error?

What’s wrong with the following:

javascript:%20var%20bcv='getVerses.php?bk=0&ch=0&vs=0&txt=0&book0=1&chapter0=1&verse0=&book1=&chapter1=&verse1='+
'&txtarea0='+document.getElementById('txtarea_0').value+
'&txtarea1='+document.getElementById('txtarea_1').value+
'&txtarea2='+document.getElementById('txtarea_2').value+
'&txtarea3='+document.getElementById('txtarea_3').value+
'&txtarea4='+document.getElementById('txtarea_4').value+
'&txtarea5='+document.getElementById('txtarea_5').value+
'&txtarea6='+document.getElementById('txtarea_6').value+
'&txtarea7='+document.getElementById('txtarea_7').value+
'&txtarea8='+document.getElementById('txtarea_8').value+
'&txtarea9='+document.getElementById('txtarea_9').value+
'&txtarea10='+document.getElementById('txtarea_10').value+
'&txtarea11='+document.getElementById('txtarea_11').value+
'&txtarea12='+document.getElementById('txtarea_12').value+
'&txtarea13='+document.getElementById('txtarea_13').value+
'&txtarea14='+document.getElementById('txtarea_14').value+
'&txtarea15='+document.getElementById('txtarea_15').value+
'&txtarea16='+document.getElementById('txtarea_16').value+
'&txtarea17='+document.getElementById('txtarea_17').value+
'&txtarea18='+document.getElementById('txtarea_18').value+
'&txtarea19='+document.getElementById('txtarea_19').value+
'&txtarea20='+document.getElementById('txtarea_20').value+
'&txtarea21='+document.getElementById('txtarea_21').value+
'&txtarea22='+document.getElementById('txtarea_22').value+
'&txtarea23='+document.getElementById('txtarea_23').value+
'&txtarea24='+document.getElementById('txtarea_24').value+
'&txtarea25='+document.getElementById('txtarea_25').value+
'&txtarea26='+document.getElementById('txtarea_26').value+
'&txtarea27='+document.getElementById('txtarea_27').value+
'&txtarea28='+document.getElementById('txtarea_28').value+
'&txtarea29='+document.getElementById('txtarea_29').value+
'&txtarea30='+document.getElementById('txtarea_30').value+
'&txtarea31='+document.getElementById('txtarea_31').value+
'&txtarea32='+document.getElementById('txtarea_32').value+
'&txtarea33='+document.getElementById('txtarea_33').value+
'&txtarea34='+document.getElementById('txtarea_34').value+
'&txtarea35='+document.getElementById('txtarea_35').value+
'&txtarea36='+document.getElementById('txtarea_36').value+
'&txtarea37='+document.getElementById('txtarea_37').value+
'&txtarea38='+document.getElementById('txtarea_38').value;%20document.write(bcv);

I’m not talking about the javascript code, but the HTML page. it should have something like

<textarea name="txtarea_3" id="txtarea_3" cols="75" rows="10">
</textarea>

with the id=“txtarea_3” spelled exactly the same as what’s in the javascript code.

The source says:

JavaScript: var bcv='getVerses.php?bk=0&amp;ch=0&amp;vs=0&amp;txt=0&amp;book0=1&amp;chapter0=1&amp;verse0=&amp;book1=&amp;chapter1=&amp;verse1='+
'&amp;txtarea0='+document.getElementById('txtarea_0').value+
'&amp;txtarea1='+document.getElementById('txtarea_1').value+
'&amp;txtarea2='+document.getElementById('txtarea_2').value+
'&amp;txtarea3='+document.getElementById('txtarea_3').value+
'&amp;txtarea4='+document.getElementById('txtarea_4').value+
'&amp;txtarea5='+document.getElementById('txtarea_5').value+
'&amp;txtarea6='+document.getElementById('txtarea_6').value+
'&amp;txtarea7='+document.getElementById('txtarea_7').value+
'&amp;txtarea8='+document.getElementById('txtarea_8').value+
'&amp;txtarea9='+document.getElementById('txtarea_9').value+
'&amp;txtarea10='+document.getElementById('txtarea_10').value+
'&amp;txtarea11='+document.getElementById('txtarea_11').value+
'&amp;txtarea12='+document.getElementById('txtarea_12').value+
'&amp;txtarea13='+document.getElementById('txtarea_13').value+
'&amp;txtarea14='+document.getElementById('txtarea_14').value+
'&amp;txtarea15='+document.getElementById('txtarea_15').value+
'&amp;txtarea16='+document.getElementById('txtarea_16').value+
'&amp;txtarea17='+document.getElementById('txtarea_17').value+
'&amp;txtarea18='+document.getElementById('txtarea_18').value+
'&amp;txtarea19='+document.getElementById('txtarea_19').value+
'&amp;txtarea20='+document.getElementById('txtarea_20').value+
'&amp;txtarea21='+document.getElementById('txtarea_21').value+
'&amp;txtarea22='+document.getElementById('txtarea_22').value+
'&amp;txtarea23='+document.getElementById('txtarea_23').value+
'&amp;txtarea24='+document.getElementById('txtarea_24').value+
'&amp;txtarea25='+document.getElementById('txtarea_25').value+
'&amp;txtarea26='+document.getElementById('txtarea_26').value+
'&amp;txtarea27='+document.getElementById('txtarea_27').value+
'&amp;txtarea28='+document.getElementById('txtarea_28').value+
'&amp;txtarea29='+document.getElementById('txtarea_29').value+
'&amp;txtarea30='+document.getElementById('txtarea_30').value+
'&amp;txtarea31='+document.getElementById('txtarea_31').value+
'&amp;txtarea32='+document.getElementById('txtarea_32').value+
'&amp;txtarea33='+document.getElementById('txtarea_33').value+
'&amp;txtarea34='+document.getElementById('txtarea_34').value+
'&amp;txtarea35='+document.getElementById('txtarea_35').value+
'&amp;txtarea36='+document.getElementById('txtarea_36').value+
'&amp;txtarea37='+document.getElementById('txtarea_37').value+
'&amp;txtarea38='+document.getElementById('txtarea_38').value; alert(bcv);

I don’t see any reason why it shouldn’t work. Are the single quotes placed right?

Look very carefully at the text area 3 tag’s id value. It needs to be spelled exactly -> txtarea_3
If it’s spelled differently that what’s used in the javascript, including cAsE differences, the getElementById won’t find it, and will return NULL

I don’t understand why it’s picking on
document.getElementById(“txtarea_3”)

from all:

javascript:&#37;20var%20bcv='getVerses.php?bk=0&ch=0&vs=0&txt=0&book0=1&chapter0=1 &verse0=&book1=&chapter1=&verse1='+
'&txtarea0='+document.getElementById('txtar ea_0').value+
'&txtarea1='+document.getElementById('txtarea_1').value+
'&txtarea 2='+document.getElementById('txtarea_2').value+
'&txtarea3='+document.getElemen tById('txtarea_3').value+
'&txtarea4='+document.getElementById('txtarea_4').val ue+
'&txtarea5='+document.getElementById('txtarea_5').value+
'&txtarea6='+docume nt.getElementById('txtarea_6').value+
'&txtarea7='+document.getElementById('txt area_7').value+
'&txtarea8='+document.getElementById('txtarea_8').value+
'&txtar ea9='+document.getElementById('txtarea_9').value+
'&txtarea10='+document.getEle mentById('txtarea_10').value+
'&txtarea11='+document.getElementById('txtarea_11 ').value+
'&txtarea12='+document.getElementById('txtarea_12').value+
'&txtarea13 ='+document.getElementById('txtarea_13').value+
'&txtarea14='+document.getEleme ntById('txtarea_14').value+
'&txtarea15='+document.getElementById('txtarea_15') .value+
'&txtarea16='+document.getElementById('txtarea_16').value+
'&txtarea17=' +document.getElementById('txtarea_17').value+
'&txtarea18='+document.getElement ById('txtarea_18').value+
'&txtarea19='+document.getElementById('txtarea_19').v alue+
'&txtarea20='+document.getElementById('txtarea_20').value+
'&txtarea21='+d ocument.getElementById('txtarea_21').value+
'&txtarea22='+document.getElementBy Id('txtarea_22').value+
'&txtarea23='+document.getElementById('txtarea_23').val ue+
'&txtarea24='+document.getElementById('txtarea_24').value+
'&txtarea25='+doc ument.getElementById('txtarea_25').value+
'&txtarea26='+document.getElementById ('txtarea_26').value+
'&txtarea27='+document.getElementById('txtarea_27').value +
'&txtarea28='+document.getElementById('txtarea_28').value+
'&txtarea29='+docum ent.getElementById('txtarea_29').value+
'&txtarea30='+document.getElementById(' txtarea_30').value+
'&txtarea31='+document.getElementById('txtarea_31').value+
' &txtarea32='+document.getElementById('txtarea_32').value+
'&txtarea33='+documen t.getElementById('txtarea_33').value+
'&txtarea34='+document.getElementById('tx tarea_34').value+
'&txtarea35='+document.getElementById('txtarea_35').value+
'&t xtarea36='+document.getElementById('txtarea_36').value+
'&txtarea37='+document. getElementById('txtarea_37').value+
'&txtarea38='+document.getElementById('txta rea_38').value;%20alert(bcv);

I think I know the error now. The textareas section has a drop down of choices from 4-38 textareas to show. So it doesn’t recognize the 4th textarea.

<table>

    <tbody><tr>
    	<td>
        <select id="ta" name="ta" onchange="changeTa();">
        	<option selected="selected" value="">How Many Textareas?</option>
            <option value="3">3 Textareas</option>
            <option value="5">5 Textareas</option>
            <option value="10">10 Textareas</option>

            <option value="20">20 Textareas</option>
            <option id="taall" value="all">All Textareas</option>
        </select>
    	</td>
    </tr>
<tr><td>
<textarea id="txtarea_0" rows="6" cols="20" name="txtar0" style="border: 1px solid Red; margin: 5px; padding: 0px 5px; float: left; width: 150px; height: 70px; color: Red; font-weight: bold;"></textarea>
	<input value=" Clear txtarea_0 " onclick="tArea0();" style="border-color: Red; margin: 5px; float: left; background-color: Red; color: rgb(255, 255, 255); font-weight: bold; font-size: 12px;" type="Reset">

</td></tr>
<tr><td>
<textarea id="txtarea_1" rows="6" cols="20" name="txtar1" style="border: 1px solid Blue; margin: 5px; padding: 0px 5px; float: left; width: 150px; height: 70px; color: Blue; font-weight: bold;"></textarea>
	<input value=" Clear txtarea_1 " onclick="tArea1();" style="border-color: Blue; margin: 5px; float: left; background-color: Blue; color: rgb(255, 255, 255); font-weight: bold; font-size: 12px;" type="Reset">
</td></tr>
<tr><td>
<textarea id="txtarea_2" rows="6" cols="20" name="txtar2" style="border: 1px solid Green; margin: 5px; padding: 0px 5px; float: left; width: 150px; height: 70px; color: Green; font-weight: bold;"></textarea>
	<input value=" Clear txtarea_2 " onclick="tArea2();" style="border-color: Green; margin: 5px; float: left; background-color: Green; color: rgb(255, 255, 255); font-weight: bold; font-size: 12px;" type="Reset">
</td></tr>
</tbody></table>

The problem is that I’ve used AJAX to change the following:

<table>
 
    <tbody><tr>
        <td>
        <select id="ta" name="ta" onchange="changeTa();">
            <option selected="selected" value="">How Many Textareas?</option>
            <option value="3">3 Textareas</option>
            <option value="5">5 Textareas</option>
            <option value="10">10 Textareas</option>
 
            <option value="20">20 Textareas</option>
            <option id="taall" value="all">All Textareas</option>
        </select>
        </td>
    </tr>
<tr><td>
<textarea id="txtarea_0" rows="6" cols="20" name="txtar0" style="border: 1px solid Red; margin: 5px; padding: 0px 5px; float: left; width: 150px; height: 70px; color: Red; font-weight: bold;"></textarea>
    <input value=" Clear txtarea_0 " onclick="tArea0();" style="border-color: Red; margin: 5px; float: left; background-color: Red; color: rgb(255, 255, 255); font-weight: bold; font-size: 12px;" type="Reset">
 
</td></tr>
<tr><td>
<textarea id="txtarea_1" rows="6" cols="20" name="txtar1" style="border: 1px solid Blue; margin: 5px; padding: 0px 5px; float: left; width: 150px; height: 70px; color: Blue; font-weight: bold;"></textarea>
    <input value=" Clear txtarea_1 " onclick="tArea1();" style="border-color: Blue; margin: 5px; float: left; background-color: Blue; color: rgb(255, 255, 255); font-weight: bold; font-size: 12px;" type="Reset">
</td></tr>
<tr><td>
<textarea id="txtarea_2" rows="6" cols="20" name="txtar2" style="border: 1px solid Green; margin: 5px; padding: 0px 5px; float: left; width: 150px; height: 70px; color: Green; font-weight: bold;"></textarea>
    <input value=" Clear txtarea_2 " onclick="tArea2();" style="border-color: Green; margin: 5px; float: left; background-color: Green; color: rgb(255, 255, 255); font-weight: bold; font-size: 12px;" type="Reset">
</td></tr>
</tbody></table>

Because otherwise if changes are made the refreshing of the entire page would erase the information on the whole page.

The urlencoded spaces? the "%20"s

Ok besides that. This is placed within the a tag. For some reason the document.write doesn’t work. But it doesn’t show any errors either.

If you change the write to
alert(bcv);
do you see the url with a long properly formatted GET variable OK?

What does it mean by that?

Error: document.getElementById(“txtarea_3”) is null
Source File: javascript:%20var%20bcv=‘getVerses.php?bk=0&ch=0&vs=0&txt=0&book0=1&chapter0=1&verse0=&book1=&chapter1=&verse1=’+‘&txtarea0=’+document.getElementById(‘txtarea_0’).value+‘&txtarea1=’+document.getElementById(‘txtarea_1’).value+‘&txtarea2=’+document.getElementById(‘txtarea_2’).value+‘&txtarea3=’+document.getElementById(‘txtarea_3’).value+‘&txtarea4=’+document.getElementById(‘txtarea_4’).value+‘&txtarea5=’+document.getElementById(‘txtarea_5’).value+‘&txtarea6=’+document.getElementById(‘txtarea_6’).value+‘&txtarea7=’+document.getElementById(‘txtarea_7’).value+‘&txtarea8=’+document.getElementById(‘txtarea_8’).value+‘&txtarea9=’+document.getElementById(‘txtarea_9’).value+‘&txtarea10=’+document.getElementById(‘txtarea_10’).value+‘&txtarea11=’+document.getElementById(‘txtarea_11’).value+‘&txtarea12=’+document.getElementById(‘txtarea_12’).value+‘&txtarea13=’+document.getElementById(‘txtarea_13’).value+‘&txtarea14=’+document.getElementById(‘txtarea_14’).value+‘&txtarea15=’+document.getElementById(‘txtarea_15’).value+‘&txtarea16=’+document.getElementById(‘txtarea_16’).value+‘&txtarea17=’+document.getElementById(‘txtarea_17’).value+‘&txtarea18=’+document.getElementById(‘txtarea_18’).value+‘&txtarea19=’+document.getElementById(‘txtarea_19’).value+‘&txtarea20=’+document.getElementById(‘txtarea_20’).value+‘&txtarea21=’+document.getElementById(‘txtarea_21’).value+‘&txtarea22=’+document.getElementById(‘txtarea_22’).value+‘&txtarea23=’+document.getElementById(‘txtarea_23’).value+‘&txtarea24=’+document.getElementById(‘txtarea_24’).value+‘&txtarea25=’+document.getElementById(‘txtarea_25’).value+‘&txtarea26=’+document.getElementById(‘txtarea_26’).value+‘&txtarea27=’+document.getElementById(‘txtarea_27’).value+‘&txtarea28=’+document.getElementById(‘txtarea_28’).value+‘&txtarea29=’+document.getElementById(‘txtarea_29’).value+‘&txtarea30=’+document.getElementById(‘txtarea_30’).value+‘&txtarea31=’+document.getElementById(‘txtarea_31’).value+‘&txtarea32=’+document.getElementById(‘txtarea_32’).value+‘&txtarea33=’+document.getElementById(‘txtarea_33’).value+‘&txtarea34=’+document.getElementById(‘txtarea_34’).value+‘&txtarea35=’+document.getElementById(‘txtarea_35’).value+‘&txtarea36=’+document.getElementById(‘txtarea_36’).value+‘&txtarea37=’+document.getElementById(‘txtarea_37’).value+‘&txtarea38=’+document.getElementById(‘txtarea_38’).value;%20alert(bcv);
Line: 1

I’m guessing that the changeTa function creates more textarea-s and adds them to the page.

The problem as I see it is that var bcv has document.getElementById for all possible textareas whether or not they are there.

If you can remove those out of that, you could test to see if they exist, then either assign their values or an empty string to variables to be used by bcv

For example, if there were no textareas, the URL would end up being

getVerses.php?bk=0&amp;ch=0&amp;vs=0&amp;txt=0&amp;book0=1
	&amp;chapter0=1&amp;verse0=&amp;book1=&amp;
	chapter1=&amp;verse1=&amp;
txtarea0=&amp;txtarea1=&amp;txtarea2=&amp;txtarea3=&amp;txtarea4=

which isn’t the most efficient and has a lot of unused GET vars in it, but it would work OK

BTW it’s good to see you’re using & instead of only &
You wouldn’t believe how many so called professional apps do it the wrong way.