I have 3 text input areas, within a single form, with a preformated value, like "blue", "red", "green", and I'm in need of loading these values dynamically from a INI file instead of having them pre-written, without reloading the page, and each time I click a link. I can't have that link submitting a form.
-
It sounds a bit like you're trying to use jQuery in place of a server-side language... is that correct? With a server-side language you'd just use it to read the INI file and write out the input values...Chris Moschini– Chris Moschini2011-04-17 07:03:21 +00:00Commented Apr 17, 2011 at 7:03
Add a comment
|
1 Answer
Loading Values Dynamically
Read INI file using PHP/ASP/Ruby/Python etc etc
Output those values to 3 JS variables or an array
Get your jquery to read that variable and populate the input boxes. You can use
$('#someid').val(someVal);
Or
You can use AJAX to grab the values after the pages have loaded. Not much point in that though.
Make links not clickable
$('a').click(function(){
return false; //Link clicked but does nothing
})
8 Comments
Jack Billy
@JohnP ::: You can simply use
preventDefault(); function instead of return false;.Joricam
PS: No this is not what I need, I think I found the pipeline, please write me a snippet on how to pass a link "rel" value trough ajax onto a php file that gets the "rel" value as a POST var, performs calculations with it and then returns the output of that php file into another form? The ideia is to: 1. click a link, get its "rel" value. 2. Send that value into a php file. 3. Return the contents of that php file back (they will be 3 text input fields) 4. Paste them onto a form on the page
JohnP
@Joricam Since you're new here you might not know that asking for a complete solution without any good faith effort on your part is frowned upon. Please try it out yourself and ask a new question if you run into problem. @Jack
return false also stops event bubblingJoricam
Ok Thanks, I'm trying it right now after some hours of sleep, I need the link to retun true, thats not the problem. Best Regards
Joricam
<html> <head> <script src="ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script> <script> $(function (){ $(body).html('<p>Balls of steel</p>'); }); </script> </head> <body> </body> </html> I'm not sure about the body selector, but I tried with proper selected divs and the .html(...) is not working, does nothing, why?
|