I have one Input Text Box
How do I store 5 value in that text box
Dynamically
For that 5 Values stored In array then sorting
How is it possible without using database
Could you Plz let me know
I have one Input Text Box
How do I store 5 value in that text box
Dynamically
For that 5 Values stored In array then sorting
How is it possible without using database
Could you Plz let me know
Posting a coherent question will help get you an answer. How about telling us what the actual problem is you are trying to solve rather than your attempt at solving it.
I have one Input Text Box
I give tha 1 value to text box then click save
As same as again i give 4 values on that text box
Finally sorting that values
How is it possible without using database
Could you Plz let me know
Well if you’re not using a database, what do you expect to happen when you click “Save”? Save it to where, exactly?
If this is all happening on the same page, I can’t see how PHP would be involved. Might be better looking at JavaScript.
My guess is that the OP wants a text box where they can enter a number, click “save” and have that number appear somewhere in a list elsewhere in the browser window. Once all five values have been entered, the numbers are sorted. That could all be done in client-side JavaScript I think.
Of course, you could do it with PHP. Every time the “Save” button is clicked, the form is submitted and then re-drawn with the numbers in the separate screen area. They are also drawn as hidden fields in the form that contains the text box, so each time a new value is added, the old ones are also re-submitted. The numbers could be sorted each time one is added, or just at the end of the process.
Something like?
<html>
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
$( document ).ready(function() {
$('#saveButton').on('click', function() {
inputVal = $('#inputText').val();
$('#textBox').append(inputVal + "\n");
$('#inputText').val('');
});
});
</script>
</head>
<body>
<form>
<input type="text" value="" id="inputText">
<button type="button" id="saveButton">Save</button><br/>
<textarea rows="6" cols="30" id="textBox"></textarea>
</form>
</body>
</html>
This is not saving anything anywhere though. This way you can add “dynamically” values to the text area. This does not handle any sorting or limiting the rows to 5. Those things can also be done by adding more logic to the JavaScript code.
That’s the kind of thing I was thinking of for a JS solution. Can’t really tell without more input from the OP.
with PHP you could just set a session variable and amend that each time it saves. If it’s an array it can then just be ordered when echoing back to the screen.
Or even write the value to a cookie if the user needs to be able to come back at some point.
I have a feeling OP’s “dynamically” meant without page loads. But I might be wrong
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.