esandra Posted November 25, 2010 Share Posted November 25, 2010 I have several textboxes, each has the same id="orno<?php echo $y;?>" where y is a variable that is being incremented within the loop and I'm trying to get the maximum value that was entered in the text box orno<?php echo $y;?> here is my loop $num=100; $nump=$num / 10; $y=1; for($j=1;$j<=$nump;$j++){ for($i=1;$i<=10;$i++){ php $y++; Link to comment https://forums.phpfreaks.com/topic/219787-how-to-get-the-max-value/ Share on other sites More sharing options...
haku Posted November 25, 2010 Share Posted November 25, 2010 This sure looks like a php question, but it's posted in the javascript forum. Is it a javascript question? Link to comment https://forums.phpfreaks.com/topic/219787-how-to-get-the-max-value/#findComment-1139481 Share on other sites More sharing options...
Pikachu2000 Posted November 25, 2010 Share Posted November 25, 2010 When the loop completes, $y will hold the maximum value used in the loop. You can either assign that value to another variable, or echo it directly. (Moved thread to PHP Help . . . ) Link to comment https://forums.phpfreaks.com/topic/219787-how-to-get-the-max-value/#findComment-1139511 Share on other sites More sharing options...
esandra Posted November 26, 2010 Author Share Posted November 26, 2010 I' trying to get the maximum value entered in the textbox by javascript..y is just part of the name of the textbox Link to comment https://forums.phpfreaks.com/topic/219787-how-to-get-the-max-value/#findComment-1139713 Share on other sites More sharing options...
Pikachu2000 Posted November 26, 2010 Share Posted November 26, 2010 Then you'd need to post whatever javascript you have that isn't working. The php isn't going to help, I'm afraid. Link to comment https://forums.phpfreaks.com/topic/219787-how-to-get-the-max-value/#findComment-1139748 Share on other sites More sharing options...
esandra Posted November 27, 2010 Author Share Posted November 27, 2010 this is a very messed up javascript...i apologize function autocomplete(y){ var orno = "orno"+y; for(var i=1;i<=100;i++){ var lastorno = document.getElementById(orno).value; //gets the maximum orno //ever entered var maxorno = document.write(Math.max(lastorno)); } alert(maxorno); var nxtorno = (maxorno*1) + 1; alert(nxtorno); document.getElementById(orno).value = nxtorno; } Link to comment https://forums.phpfreaks.com/topic/219787-how-to-get-the-max-value/#findComment-1140148 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.