I want to create a classes pages. The way i want to approach is that based on what class you have chosen, the class template will populate based with content based on the class that you've chosen. I want to create one class template and let the rest of the content come from the database, the only way to do this is by making the navigating button a form button am I right or is there a more efficient way? I am using python django for server side
ie
<button type="submit" value="math">
This would imply that your page will reload every time you click, a more elegant approach would be to use some JavaScript and some AJAX like this onclick="someFunction()" and after that you use some ajax to populate your page.
Related
I'm building a website using the ACF plugin (Version 5 Pro), and I'm setting up a button on a page template, which by itself isn't the problem. The problem is that depending on the specific content of each individual page using that template, the button can have one of several different appearances. What I'm trying to do is set things up so that I can upload all the buttons into the default value section of the ACF field ahead of time, and then every time I make a new page using that template, simply select the appropriate button from a radio button, a dropdown menu, or something similar on the backend of the page. I plan to be constantly uploading small amounts of content using this template, so not having to manually select the appropriate images on each page would save me a lot of time.
I've googled around and there wasn't a good answer I could find anywhere, so I'm hoping one of you more knowledgeable folks could help me out!
(And before anyone proposes this as a solution, no, the content of each page isn't something I can define just using programming. It's a little more abstract and needs human input. If all else fails I can just make multiple templates and simply select the appropriate one when I go to make a page, but the way I'm trying to do it now would be a lot cleaner).
You can try ACF Flexible Content:
https://www.advancedcustomfields.com/add-ons/flexible-content-field/
Using Flexible Content field, you will be able to create multiple fields (button 1, button 2, etc) including a WYSIWYG editor and build the buttons HTML adding the default value of the field.
You can read:
https://support.advancedcustomfields.com/forums/topic/html-default-values/
However, I think you'll get in trouble making your buttons dynamic with this approach... so I'd suggest it will be better if you keep some parts of the buttons (like URLs) dynamic, using an extra field to enter the URL, anchor, etc.
I'm trying to show a modal form window into some static html pages to request a users information and connect this with a Rails application.
I have a dynamic Rails application that save the user's information with a gem Devise in the side of my server.
The creation of modal windows in Rails with Bootstrap seems simple but I do not know if that view can be embedded as javascript into the static pages or if should create the modal form directly in the static page for later send user data to my application rails.
Any ideas would be greatly appreciated. Thanks in advance.
You've got three options:
A) render the html for the form out in advance in a hidden div, then just copy that into the modal.
B) construct the form in javascript, perhaps using a sort of "blank" form with a few missing details, then render the result into the modal
C) use javascript to make a call to the rails back end (which supplies the form html), and when you get it, load it into the modal.
Which choice you use depends on how much dynamic content is in your form. C is the slowest option but simplest in a way since your form will always be built from scratch in rails, which can use the appropriate data. This is suited to a situation where you are looking at lots of records on the page, each of which has a lot of data, and you want to click on one to edit some of the data.
If, for any given page, the form can be generated in rails on initial page render, then you could do A as all of the dynamic elements will be available in your controller in the first place. This is well suited to a page where you are looking at a single record, and want to show an edit form in the modal: because there is only one record to choose between, you always know in advance how to make the form for it.
B is sort of a half-way stage: if you don't know in advance what you will need to load into the form, but the difference between the form "options" is very small then you could fill in the blanks with JS. This is probably the most complicated solution as you'll need to write the JS yourself, but it's more efficient than C.
I'm considering adding multiple languages to my website and looking for ideas on how to possibly implement. My website is static however and I'm curious if there is a way without PHP to allow the website to flip between different languages via a button. I've seen various questions asking how to do this task using PHP, however can it be done without PHP?
For example, can a static website switch between different languages in the same way that a webpage can easily swap stylesheets using javascript or jquery?
There are several methods you can use. One way is to adapt the script used here:
How do I toggle multiple divs individually?
You can place all the translated text in one page but hide them in separate divs such that only one div shows. Then you can hook button click events to change the visible div whose language you would like to show.
An alternative is to implement AJAX calls to retrieve different html pages depending on the selected language.
In my aspx page I have repeater to show list something, I want to add new row and show it in repeater without postback. I will send date soon. I don't want to use AJAX
How to add row to asp:repeater by JavaScript?
The best bet is inpect the code using a tool like firebug retrieve the html for the row, and recreate that using javascript and attach it to the DOM. Dirty but doable. Using something like jquery will make your work easier.
I know you dont want to use AJAX but the cleanest method would be to use an UpdatePanel and do is on the server side using a partial postabck
The repeater just generates repeating html so it's definitely possible to insert new html by using javascript. As #mellamokb mentions those changes won't be visible on the server side.
It's generally a bad idea to mix client and server side rendering with ASP.NET Webforms.
In the case of a list of some kind being dependent on e.g. a combobox it's often a better idea to render lists for all options in the ASPX code. Then use javascript to hide every list except the currently active one.
I'm relatively new to web application programming so I hope this question isn't too basic for everyone.
I created a HTML page with a FORM containing a dojox datagrid (v1.2) filled with rows of descriptions for different grocery items. After the user selects the item he's interested in, he will click on the "Submit" button.
At this point, I can get the javascript function to store the item ID number as a javascript variable BUT I don't know how to pass this ID onto the subsequent HTML page.
Should I just pass the ID as an URL query string parameter? Are there any other better ways?
EDIT: The overall process is like a shopping cart. The user will select the item from the grid and then on the next page the user will fill out some details and then checkout.
I should also mention that I'm using grails so this is happening in a GSP page but currently it only contains HTML.
You could just use a hidden input field; that gets transmitted as part of the form.
<html>
<head>
</head>
<body>
<script type="text/javascript">
function updateSelectedItemId() {
document.myForm.selectedItemId.value = 2;
alert(document.myForm.selectedItemId.value);
// For you this would place the selected item id in the hidden
// field in stead of 2, and submit the form in stead of alert
}
</script>
Your grid comes here; it need not be in the form
<form name="myForm">
<input type="hidden" name="selectedItemId" value="XXX">
The submit button must be in the form.
<input type="button" value="changeSelectedItem" onClick="updateSelectedItemId()">
</form>
</body>
</html>
It's good one, but better is to use some script language such as JSP,PHP, ASP....and you can use simple POST and GET methods.
The best method (imho) is to include it in the URL
href="http://NewPage.htm?var=value";
encodeUriComponent a string Value
One way to send over variables using POST to another page is to make the link to the subsequent page a submit input on a form where the action attribute is your target page. For every variable you have, you can include using inputs of attribute type "hidden" in this form, making only the button visible.
Another option is to dynamically generate links on the page with something like PHP where you basically repopulate the current GET queries.
Finally, you can always store this information in the PHP $_SESSION array and not have to worry about continually passing these variables through site navigation.
Your choice will depend on how many navigational options there are where you'd like to keep the same variables. It will also depend on how secure you'd like your back end to be and the amount you'd like to disclose to the advanced web user.
If you are only going to need the ID on the subsequent pages, then you can pass the id as a query string parameter.
But there will be times when you need to relay more information and passing a variety of parameters to different pages and having to maintain different sets of parameters for different pages can get a little hairy. When this is the case I'd suggest that you keep a hidden field on the form and create an argument object that stores each of your parameters. Serialize the argument object with JSON and store this in you hidden field. Post the form back to the server. When the next page loads, deserialize the object and retrieve the values you need.
Assuming that you are limited to using html pages, I think the best approach would be to pass the id along on the query string to the next page. It is relatively easy to pull that value back off the query string on the next page. If you need to be a little more stealthy about passing the variable (or you need the variable to persist for more than one page), you could also set a cookie and retrieve it on the next page.
Since you are trying to do this in a Grails application you do have a choice of using Flash scope. This might not make any sense if you want to go directly from one HTML page to the next as the scope would be defined in a controller. If you do not need to do any sort of processing between requests, I'd suggest using a hidden form field to keep it simple.
http://grails.org/Controllers+-+Controller+Scopes