I have a snippet of HTML here:
[code=html] <p><a title="" href="#pc" onclick="sendEc ardRequest(prev _ecard());">Pre vious</a> | <a title="" href="#pc" onclick="sendEc ardRequest(next _ecard());">Nex t</a></p>
<p class="ctr"><sp an id="ecard_id_la bel"></span></p>[/CODE]
And javascript here (not all of it - just the relevant bit)
[code=javascript] function sendEcardReques t(id) {
http6.open('get ', 'ajax/ajax-ec.asp?cat=44&i d=' + encodeURICompon ent(id));
http6.onreadyst atechange = handleEcardRequ est;
http6.send(null );
}
function handleEcardRequ est() {
// If everything iss okay:
if(http6.readyS tate == 4){
// Assign the returned value to the document object.
document.getEle mentById('ecard _id_label').inn erHTML = http6.responseT ext;
}
}
function prev_ecard() {
MyEcardVar--;
if (MyEcardVar <= 252) {
MyEcardVar = 252
}
return MyEcardVar;
}
function next_ecard() {
MyEcardVar++;
if (MyEcardVar >= 4467) {
MyEcardVar = 4467
}
return MyEcardVar;
}[/CODE]
My SQL will get the ID from the javascript - e.g.:
This works fine if the photos in the photo table are all spaced one apart, but in my data, I have the photoIDs as:
252
3048
3052
4010
So unless the user presses next nearly 3,000 times, they won't get any extra photos appearing via the SQL.
Is there any way the javascript can send the next valid ID, instead of only incrementing by 1? If this was a standard page, I could write the next valid number to the page, in the javascript, but I can't do that in this case as it's ajax.
Does this make sense? Sorry if I haven't explained myself very well.
Any advice gratefully received. Thanks.
[code=html] <p><a title="" href="#pc" onclick="sendEc ardRequest(prev _ecard());">Pre vious</a> | <a title="" href="#pc" onclick="sendEc ardRequest(next _ecard());">Nex t</a></p>
<p class="ctr"><sp an id="ecard_id_la bel"></span></p>[/CODE]
And javascript here (not all of it - just the relevant bit)
[code=javascript] function sendEcardReques t(id) {
http6.open('get ', 'ajax/ajax-ec.asp?cat=44&i d=' + encodeURICompon ent(id));
http6.onreadyst atechange = handleEcardRequ est;
http6.send(null );
}
function handleEcardRequ est() {
// If everything iss okay:
if(http6.readyS tate == 4){
// Assign the returned value to the document object.
document.getEle mentById('ecard _id_label').inn erHTML = http6.responseT ext;
}
}
function prev_ecard() {
MyEcardVar--;
if (MyEcardVar <= 252) {
MyEcardVar = 252
}
return MyEcardVar;
}
function next_ecard() {
MyEcardVar++;
if (MyEcardVar >= 4467) {
MyEcardVar = 4467
}
return MyEcardVar;
}[/CODE]
My SQL will get the ID from the javascript - e.g.:
Code:
SELECT photo FROM tbl WHERE photoID > "&id&"
252
3048
3052
4010
So unless the user presses next nearly 3,000 times, they won't get any extra photos appearing via the SQL.
Is there any way the javascript can send the next valid ID, instead of only incrementing by 1? If this was a standard page, I could write the next valid number to the page, in the javascript, but I can't do that in this case as it's ajax.
Does this make sense? Sorry if I haven't explained myself very well.
Any advice gratefully received. Thanks.
Comment