Forum Moderators: open

Message Too Old, No Replies

navigate buttons

navigate buttons

         

xbl01234

11:14 pm on Sep 22, 2007 (gmt 0)

10+ Year Member



Hi;
I am trying to write a list navigate battons for the user navigate differet web page,
it is like this forum does.
For example, a list a buttons of the '<', '1', '2', '3' and '>', user could use it to navigate
with different page.

The problem i have is there are not reaction from the buttons of the '1', '2' and '3',
when i click on these buttons, but the buttons of the '<' and '>' works fine.

Could you help me to find out problem, please.

all the work i have done as following:

in the .htaccess, i wrote a modrewrite rule.


RewriteEngine On
RewriteRule ^country/([0-9]+)/$ /Category.php?page=$1 [L]

and the i wrote some code for these buttons.


<input type="button" id="b<" name="b<" value="<" onClick="nextFunction('<')" />
<input type="button" id="b1" name="b1" value="1" onClick="nextFunction('1')" />
<input type="button" id="b2" name="b2" value="2" onClick="nextFunction('2')" />
<input type="button" id="b3" name="b3" value="3" onClick="nextFunction('3')" />
<input type="button" id="b>" name="b>" value=">" onClick="nextFunction('>')" />

//////////////////////////////////////////
<?php
$category= $_SERVER['REQUEST_URI'];
$cat=explode("/", $category);
$myStr=$cat[1];

?>
///////////////////////////////////////////

<script type="text/javascript">
var myChar; // global variable

function nextFunction(mystr) {
myChar=mystr;
window.setTimeout("delayit()", 1000);
}

function delayit() {

if(myChar=='<'){ //it has reaction here
newV1=document.getElementById('b1');
newV1.value=parseInt(newV1.value);
if(newV1.value==1)
return;
else{
newV1.value=parseInt(newV1.value)-1;
var newV2=document.getElementById('b2');
newV2.value=parseInt(newV2.value)-1;
var newV3=document.getElementById('b3');
newV3.value=parseInt(newV3.value)-1;
}
}
else if (myChar=='>'){//it has reaction here
newV1=document.getElementById('b1');
newV1.value=parseInt(newV1.value)+1;
var newV2=document.getElementById('b2');
newV2.value=parseInt(newV2.value)+1;
var newV3=document.getElementById('b3');
newV3.value=parseInt(newV3.value)+1;
}
else{
window.location.href = "/" + "<?php print($myStr)?>" + "/" + myChar + "/";
}// this part does not has reaction.?
}

</script>

/////////////////////////////////////////////////////////////////////////////////
But if i rewrite the javascript code to following, and the rest do not change,it does job, i do not why.

<input type="button" id="b<" name="b<" value="<" onClick="nextFunction('<')" />
<input type="button" id="b1" name="b1" value="1" onClick="pageFunction('1')" />
<input type="button" id="b2" name="b2" value="2" onClick="pageFunction('2')" />
<input type="button" id="b3" name="b3" value="3" onClick="pageFunction('3')" />
<input type="button" id="b>" name="b>" value=">" onClick="nextFunction('>')" />
////////////////////////////////////////
<?php
$category= $_SERVER['REQUEST_URI'];
$cat=explode("/", $category);
$myStr=$cat[1];

?>

///////////////////////////////////////////
<script type="text/javascript">
function pageFunction(myChar){
window.location.href = "/" + "<?php print($myStr)?>" + "/" + myChar + "/";
}
</script>

//////////////////////////

<script type="text/javascript">
var myChar; // global variable

function nextFunction(mystr) {
myChar=mystr;
window.setTimeout("delayit()", 1000);
}

function delayit() {

if(myChar=='<'){
newV1=document.getElementById('b1');
newV1.value=parseInt(newV1.value);
if(newV1.value==1)
return;
else{
newV1.value=parseInt(newV1.value)-1;
var newV2=document.getElementById('b2');
newV2.value=parseInt(newV2.value)-1;
var newV3=document.getElementById('b3');
newV3.value=parseInt(newV3.value)-1;
}
}
else if (myChar=='>'){
newV1=document.getElementById('b1');
newV1.value=parseInt(newV1.value)+1;
var newV2=document.getElementById('b2');
newV2.value=parseInt(newV2.value)+1;
var newV3=document.getElementById('b3');
newV3.value=parseInt(newV3.value)+1;
}
}
</script>

phparion

8:46 am on Sep 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



first of all it is not a PHP forum question at all and I am not sure why Mods have not moved it to javascript forum yet,

secondly, your ELSE is not called to redirect on number basis and not on < > basis.

what you need to debug is put ALERT() in your else where it should use NUMBER to redirect and make sure you are taken to that ELSE body when a number is clicked.

also print your

"/" + "<?php print($myStr)?>" + "/" + myChar + "/";

in alert() etc to see if all values are knitted there properly.

third thing should be to check your Javascript error console / log to see what error browser throws.