There are 4 li items as above and I want the value from each hidden input field. At the moment I am getting 4 identical values, 1, 1 ,1 and 1.
Does anyone know how to get them and what I am doing wrong. I really need them in an array. It’s probably simple but I’ve just been looking at it for too long
Thanks Paul, u always have the answers
What time is it in New Zealand right now? I am in the UK and you seem to be online programming all hours! I have been at it since 8am too, trying to build myself a custom CMS system for client’s websites and doing the front-end with lots of UI widgets
That looks pretty heavy but I shall give it a try when I get a chance.
I have a very arty background, originally a musician, I changed profession an took an electronics degree back in 2006. Since then I have only worked as a web developer because I find it more interesting.
Its strange, even though I haven’t been doing programming all that long and am probably nowhere near someone like you (javascript guru :P), I find that the more I develop, I am actually becoming more mathematical if that makes sense? Guess it’s part of your brain that once you start using, sharpens. And I was already 30 when I changed so who says you can’t teach an old dog new tricks! LOL
Thanks for all the help btw lots of people don’t seem to reply on here nowadays
.val is a method that works only with jQuery objects.
In that each function, the this keyword is a direct reference to the element itself.
Use the native technique to get a form elements value, with this.value
Either that, or wrap (uselessly some might say) the this keyword in a jQuery object, to end up with $(this).val()
Yes I have come across this before, I am so pleased that I am able to understand it now. It explains JavaScript’s refusal to do a lot of similar things.
thanks again !
I was going to say I have used serialize() before but that was when there was a form present, there isn’t in this instance so that isn’t an option. That is absolutely great as I’m sure you know it collects all form input results into an array. Great for lazy person like me
Yes that’s what I thought too, but id is supposed to be an array because of
$id.push(this.value) thats why I don’t expect it to be a string and even if it were just a string, the code I have on my php script to test is as below:
if (isset($_GET['id'])){
echo("Id set!");
}
Even when I send that string as a url variable as above, it doesn’t register. However, The array ‘order’ does register.
Work backwards on the problem. Start from how you want to access the data in PHP, then figure out how the data needs to be structured, and then finally organise the submitted data so that its matches that structure.
I could easily transfer this variable to the php script if it were in a form but with this part of the interface, I don’t want to have a form, I want to handle everything from one button - jquery click, get all of the current image indexes(sortable, ‘serialize’ - ‘order’) , get all of the id’s(hidden input fields) send them via GET to the script.
When it reaches the script I need to take all of the GET data make a db query which re-order’s the image indexes according to the previous user (sortable) order.
So thats what I need to accomplish, I have all of the pieces together except for the GET variable id.
maybe there is an easier way, I shall work backwards yes.