So this website basically delivers flowers to people and depending on how far away the shipment is, it's going to cost more for the shipping. There are two prices: 12.95 and 30.00. The owner of the website wants it to automatically say "12.95" before a zip code or anything is typed in because he says its "turning people away" to see 30.00 like that. If they type the zip code in, it isn't a problem. It'll display the correct amount. I need it to say 12.95, or be totally blank until a zip code is typed in, by default instead of 30.00. any suggestions?
EDIT 1
The zip code input and the radio button to select the price are on 2 different pages. Theyre under 1 larger umbrella page, but it doesnt seem to be able to detect the zip code tag OR the radio button/label. Thats why i cant simply make it invisible until a zip code is typed. because i can't bridge javascript across two pages like that.
EDIT 2
well im not sure how all 3 pages come together, but im assuming that the zip code page and the radio button page are "included". they arent part of the actual document, so they cant be accessed via the DOM. when theyre displayed on the page, all the code comes together as a whole. or it appears that way. so i tried to manipulate the variables via the dom but it couldnt find them. then i tried to change things via cookies but that gave me a world of shit too. didnt work
Set the price to 12.95 and set an onChange eventListener to the zip code input that will recalculate the price.
$('#zipCode').change(function() {
updatePrice($(this).val());
});
It's hard to give specifics without actual code, sorry.
The answer was document ready, in jQuery. That's why I couldn't modify the code from the umbrella page; the page wasnt completely loading by the time my scripts were being executed. Here's the code I used:
<script>
$j=jQuery.noConflict();
$j( document ).ready(function() {
if (document.getElementById("shipping:postcode").value != "") {
document.getElementById("labelbutton_super").style.display='block';
} else {
document.getElementById("labelbutton_super").style.display='none';
}
});
</script>
Related
I have been using Custom extension for "Quick View" on every product like this
when hover the image, that link will show. when click that link, it will show with detailed description with big image. Its working well in product list page. But in home page, I got error like "TypeError: d is undefined" in img_height.js line no.7
I have checked that file and give alert for to find what value hold by d.I got an alert like [object object].(Multiple alerts were came).
d=Element.retrieve(a,"prototype_event_registry",$H()));
alert(d); //undefined d
var e=d.get(b);
Object.isUndefined(e)&&(e=[],d.set(b,e));
After closing alert boxes by check the checkbox "prevent this page from creating additional dialogs".
At that time, I got Error like "NS_ERROR_NOT_AVAILABLE: "
But I got alert box only in home page, Not in product list page. After giving alert, Quick Look working well in home page too. But if i remove alert, again i got same error "TypeError: d is undefined"
And also in between, I got most of the errors like "$.browser is undefined","typeerror $(...).live is not a function". I have fixed those issues by adding this script "<script src="http://code.jquery.com/jquery-migrate-1.0.0.js"></script>"
But i can't able to whats the real issue. This issue consumed around 3 days of my time. Still i didn't get any idea about why its happend like this.
If anybody have an idea, please save me guys.....
When this kind of thing happens to me it is either:
a) Because the product page is loading some extra scripts that aren't present on the home page. In this case, study the page source of the product page and check all the scripts that are loaded and all the inline scripts. Compare this to the page source for the home page being very careful to distinguish between different versions of jQuery and ensuring that jQuery is always .noConflict() so that Magento's prototype.js can own $. Maybe the home page has some other module that loads a different version of jQuery before or after your Quick Look scripts.
Or
b) Because some HTML element that the script needs is not present on the HTML page. So for example the product page might have a DOM element <div id="my-special-quick-look-box"> that the JavaScript will reference, but on the home page maybe this element is missing or in an unexpected ancestor-child relationship. Or, the div is present but the CSS means it has no height or is missing some property that the JavaScript is trying to reference.
Or
c) If all the JavaScript is combined into one file, it changes the running order and often some DOM element that will be there later is not there when the script is run. So if you have combined JavaScript take care over the running order and use the DOM events to know what has loaded when and then run the JavaScript at the right time.
That is my experience. Maybe it will help you find the bug.
IS there a way to post a $var to $PHP_SELF so that I can use it further down the script?
After 2 hours reading dozens of questions which helpfully appear in the sidebar to the right,
it became apparent that they pretty much all assume an HTML Form has been / will be
activated.
But psuedo~code of what I need looks more like this:
< php
$someVariable=y;
$otherVar=X;
// and the usual setup for accessing the `$_POST` of php:
$HokeyDino=`$_POST`["SendOFF"];
$SendOFF=101;
// etc. and then come to a point where I need the script to just automatically post a value
[ the lack of knowledge ]
// which if I had tha codez!
// would permit the use of that $var, $HokeyDino ...
if($HokeyDino==100){
// do stuff
}
I don't like looking foolish, but gotta ask away, because I figure I have missed learning some elementary aspect of programming, being self-taught so far, but not knowing what might be lacking makes it hard to go look productively.
Thanks very much!
EDIT // Clarification.
Wow, this is amazing. half an hour, 24 people reading the question. Blows my mind.
Right. What I have gotten done so far to give more background:
A php script which uses fopen to create on the fly another php / html page, and all the
code on the Authouring originating script, to write (a+) to the newly created temp page, the whole thing.
From a loop on the authouring page, I have code for retrieving POSTS I send TO that temp page, and that code gets written to a very temp page... then I cause the first part of the page to be written, to get placed on the Temp page, by put_contents etc.,
Next, from another loop on the Authouring page, I write code which item by item matches the things which were included in the < head > of the Temp page.
Anyhow, without graphics, it's a bit tough to explain. What I have at the point I have gotten to so far, is the newly created/assemble Temporary page, can be accessed as a WebPage,, and a button click on it, will successfully POST a value back to the originating/Authouring script.
Here's the tricky part: There isn't any way I was able to devise, to dynamically create code ON THE AUTHOURING page, to recieve POSTS from the Temp Page.
But I realized that if, in the Loops on the Authoring Page, I was able to $PHP SELF post a
string which would be the code for creating a * $Var = $ POST; to catch the values from button clicks on the TEMP page, it would work.
Critical, is that the Authoring Page, doesn't know how many buttons will be made over on the Temp Page ~ that depends on the number of items in the database, which the loops are reading and translating into code which builds the Temp Page.
So, there is no way to hard~code, on the Authouring Page, all possible code for recieving posts, but I could use one Universal $Var= $ POST[ X ] if I could generate it on the fly in the loop, on the Authoring Page.
Hence the need to write code which will $SELF POST, and have it triggered just by normal programme flow, and not the click of a button in a form.
Hmm.... clear as mud yet? :) the question still is pretty straight foreward.
Cheers!
//// Loop
Create CViewerTemp
read DB and manipulate data
Loop B
create, and write to VeryTempHead page
code which creates the top of CViewer, HEAD items
create, and write to VeryTempBody page
code which will work there, items one by one matching head items
end Loop B
Write code which is 1ne time only stuff, to begin CViewer.
then transfer the stuff from VeryTempHead page, into CViewer, kill
VeryTempHead
then transfer the stuff from VeryTempBody to CViewer, kill Very Temp Body.
Open CTempViwer, click on a Button, a value gets posted to Authouring Page.
Authouring Page doesn't recieve anything, no code to do so exists [YET! :)]
If you want to create data on the fly, but not from $_POST, you can just populate $_POST from any other source like this:
<?php
// some calculations
$_POST['my_var'] = $some_calculated_stuff;
// later in your code
if(isset($_POST['my_var'])) {
// works as if it had been posted
}
?>
Is this what you're looking to do?
It's a bit hard to follow, so I'll suggest another potential:
Have you taken a look at cURL?
I think you mean hidden input fields. You can print them with php and they will be posted to your next php script.
Please note, that the user can change the values and you shouldn't trust them.
Also, you can consider using $_SESSION. That would be the better way to solve the task.
Please note that you shouldn't use PHP_SELF because it's insecure.
I have a php "add classified" page where users may fill in details in several drop-lists.
At the bottom, I have a picture upload tool, which requires the page to submit to itself, and then preview that image.
Problem is, whenever this is done the drop lists values are resetted, so the users have to re-select everything.
I have asked this Q before, but the method I went with doesn't work I have noticed now...
here is the Q:
'Remember' form drop list value when submitting to SELF?
I have managed to solve this, as mentioned above, by using javascript with PHP to "grab" the value of the chosen option, and then use the value which has an ID with the same name exactly, and add a selected tag to it. See below: (this js is at the bottom of the page)
var areaOption = byId("<?php echo #$_POST['annonsera_area'];?>") || "Välj Län";
areaOption.selected=true;
The problem here is that whenever an element has the same id as another one, it wont work. And I have to use same ID:s, because alot of the options are "years" which the users may select as "make year" of their "vehicles"...
Anyways, is there any other way to solve this?
Thanks
Have you considered using an AJAX-style file upload script? For example:
http://www.uploadify.com/
This would allow your users to upload an image to the page without having to submit the entire form or refresh the page.
Technically you shouldn't have identical IDs. Try to rethink how you are doing it, but otherwise, you could use AJAX (assuming that you are happy to only support people with javascript enabled).
Further to my question yesterday (here), I am working on a webpage that has a section that shows 'live' order details.
The top half of my webpage has Spry Tabbed Panels. One of the panels contains an include call to a separate php page that I have created (getOpenOrders.php). This contains an SQL query to obtain all open orders and then puts the details into a table.
As a result, the table of open orders is shown in the Spry panel. What steps do I now need to take to have this refresh every 15 seconds?
Do you really want to call the database every 15 seconds for each user? isn't that an overload?
I'm not saying that your database will be overloaded, but, thats how you shouldn't do things!
Edited
you should show an image, or the link to that page in order to gt an appropriate answer, because it all depends in what are you doing in the table.
because I don't know, I will give you an answer on what probably is happening.
Because you said that you're new to the ajax world, let's make things simple, and not to complicate on the you should return a JSON object and use it to re populate your table. :)
So we will start with 2 buttons (Previous and Next) so the user can move the data that is showing (you probably don't want to give him/her 100 lines to see right?)
let's say that you have 2 pages, a showData.php and getTable.php, in the showData.php you will need to load jQuery (wonderful for this) and add a little code, but where the table is to be placed, just add a div tag with an id="myTable" because we will get the data from the getTable.php file.
getTable.php file has to output only the table html code with all the data in, without no html, body, etc... the idea is to add inside the div called myTable all the code generated by getTable.php
Let's imagine that getTable.php gets a page variable in the queryString, that will tell what page you should show (to use LIMIT in your MySQL or PostgreSQL database)
You can use jQuery plugin called datatables witch is one of my choices, check his example and how small code you need to write! just using jQuery and Datatables plugin.
The first description follows the jQuery.Load() to load the getTable.php and add as a child of the div and wold do this for the previous and next buttons, passing a querystring with the page that the user requested. It's to simple and you can see the website for that, if you prefer to use the DataTables plugin, then just follow their examples :)
if you, after all this need help, drop me a line.
<META HTTP-EQUIV=Refresh CONTENT="15; URL=<?php print $PHP_SELF ?>">
This should be in between the head tags.
-or-
header('Refresh: 15');
This should be before the head tag and directly after the html tag.
As said by balexandre, a different method should be used. One that does not require a database hit every 15 seconds for every single user that is connected to the site. But, there is your answer anyways.
Although, balexandre makes a very good point, if you do decide that you need a refresh, you could simply do something like this in your JavaScript:
window.onload = function( )
{
setTimeout( 'window.location.refresh( )', 1500 );
}
(I've not tested the above code, so syntax may need to be tweaked a little, but you get the idea)
I've created a page using JQuery and Ajax that helps a user filter through a series of options and ultimately displays a filtered list of products meeting their specification.
This all works fine.
The problem i'm having is the "Back Button" problem with Ajax, i know how to get around this with anchors on static content (i.e. Filter.php#Step2).
However, the page works by returning a list of product specifications, when a spec link is clicked, Ajax loads the same page again applying the links parameters, this is repeated up to six times, after which, the user is redirected to the filtered product URL.
If the user then clicks "Back", then of course, the filter page reloads from step 1 rather than the last step (step 6).
Does anyone know if this is even possible?
Every time you want to be able to go back to the previous step, change window.location.hash.
Ie.
window.location.hash = 'step1';
This changes the #foo part in the URL. You will also need a timer in JavaScript which checks if the hash was changed, as there is no way to reliably detect hitting the back button. Something along the lines of...
var oldHash = window.location.hash;
setInterval(function(){
if(window.location.hash != oldHash) {
//the hash was changed, do something
}
}, 50);
I hope this helps
I can't say I've implemented this before personally, but I remember the jQuery Tools tab component doing something similar. I'm not sure if it will work for your particular situation, but it may be worth looking at their approach as a starting point.
jQuery Tools AJAX:ed tabs with History support