SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    url string error?

    What's wrong with the following:
    Code JavaScript:
    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);
    Compare bible texts (and other tools):
    TheWheelofGod

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,232
    Mentioned
    194 Post(s)
    Tagged
    2 Thread(s)
    The urlencoded spaces? the "%20"s

  3. #3
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague View Post
    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.
    Compare bible texts (and other tools):
    TheWheelofGod

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,232
    Mentioned
    194 Post(s)
    Tagged
    2 Thread(s)
    If you change the write to
    alert(bcv);
    do you see the url with a long properly formatted GET variable OK?

  5. #5
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague View Post
    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
    Compare bible texts (and other tools):
    TheWheelofGod

  6. #6
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't understand why it's picking on
    document.getElementById("txtarea_3")

    from all:
    Code JavaScript:
    javascript:%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);
    Compare bible texts (and other tools):
    TheWheelofGod

  7. #7
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,232
    Mentioned
    194 Post(s)
    Tagged
    2 Thread(s)
    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

  8. #8
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The source says:
    Code JavaScript:
    JavaScript: var bcv='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; alert(bcv);
    I don't see any reason why it shouldn't work. Are the single quotes placed right?
    Compare bible texts (and other tools):
    TheWheelofGod

  9. #9
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,232
    Mentioned
    194 Post(s)
    Tagged
    2 Thread(s)
    I'm not talking about the javascript code, but the HTML page. it should have something like
    HTML Code:
    <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.

  10. #10
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague View Post
    I'm not talking about the javascript code, but the HTML page. it should have something like
    HTML Code:
    <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.
    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.
    Code HTML4Strict:
    <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>
    Compare bible texts (and other tools):
    TheWheelofGod

  11. #11
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem is that I've used AJAX to change the following:
    Code HTML4Strict:
    <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.
    Compare bible texts (and other tools):
    TheWheelofGod

  12. #12
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,232
    Mentioned
    194 Post(s)
    Tagged
    2 Thread(s)
    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
    Code:
    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 &amp; instead of only &
    You wouldn't believe how many so called professional apps do it the wrong way.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •