Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to create a dynamic form on my website.
On my site a have several forms that are subject specific but i also have a contact us form with a subject dropdown from which they can choose any of the subjects that the subject specific forms cover.
now if they select website design enquiry i need to ask them for their website address whereas website address isn't relevant to all of the other enquiry subjects, if they ask about website hosting i again need their website address but also need their preference of hosting package.
if they ask about mobile app development i don't need the website or hosting package fields but need 4 checkboxes to appear to allow them to tick the ones relating to the platforms for which the mobile app is to be developed for.
so it needs to be auto adaptive to the type of enquiry selected.
how can i acheive this?
you can use jQuery, to achieve that.
you need to add jQuery change listener on the dropdown select. then you add form elements to a container accroding to selected value.
here is a small example
$( ".select" ).change(function() {
var value = this.val();
if(value == "webDesign")
{
$("#fieldsContainer").append('<input name="webUrl" class="inputField"/>');
}
});
you can also change action url accroding to select Value so it will be more easy to handle different forms
if(value == "webDesign")
{
$("form#myForm").attr('action','process.php?type=webdesign');
}
Your question is quite vague, but the answer to it is that there are many ways to achieve it. One of the most commonly used ways is to use javascript (or some library like jQuery using js).
I have put together a basic function for you that will showcase how it's done in pure js:
HTML:
Services: <select id="service">
<option value="stuff">stuff</option>
<option value="webdesign">webdesign</option>
</select><br />
<span id="webname">Website: <input type="text" /></span>
JS:
document.getElementById("service").onchange = function () {
if (document.getElementById("service").options[document.getElementById("service").selectedIndex].value == "webdesign")
document.getElementById("webname").style.display = "none";
else
document.getElementById("webname").style.display = "block";
}
Here is the demo page of the above code: http://jsfiddle.net/w3pGr/
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I need to save the whole HTML page or a part of it into the database with all values entered by the user in input fields and the states of radio buttons etc... but when I try to do so the page is saved without the modifications made by the user.
Is there any way to save them too?
By "Save HTML page" i mean using jquery to save the innerHTML for a selector.
My goal is to save a particular section of my page on the server as HTML document after the user enters values in input fields. I managed to do that with jquery, but the problem is that the values which were entered by the user are not present in the saved document. so when i open the saved html, i want the values that were entered by the user to be shown in input fields. i dont want to collect them with JS and to fill them again, i just want to save the page as it is and view it later, i know this sounds like bull!##% but this is what i have to do now.
I think you can use jquery's attr().
example
<div id="inputs">
<input type="text" id="input_1">
<input type="text" id="input_2">
<input type="text" id="input_3">
</div>
<button id="btn">save value</button>
<script>
$('#btn').click(function() {
var $input = $('#inputs').find('input');
var inputLen = $input.length;
for (var i = 0; i < inputLen; i++) {
$input.eq(i).attr('value', $input.eq(i).val());
}
});
</script>
On Chrome, print page, when the print dialog comes up save the destination to "save as a PDF" and the save the file. Then just print the PDF file you saved.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want a html page with simple question 1 + 2 and when user puts 3 it delayed redirects to another url after 3 seconds?
Basically I want a code for this. I apologize if it's too broad or inapropriate. But I need help right now.
I do not recommed asking people to write code for you on StackOverflow because this is a community where you ask questions and it gets answered. With that being said, I am bored so I will help you.
Using HTML and JQuery, we have an input and a button. When the button is pressed, it runs the function testInput(), which checks if the value of the input is equal to three, then if it is we wait 3 seconds then redirect them. Here is a working snippet:
function testInput() {
var inputVal = $("#inputBox").val();
if (inputVal == "3") {
setTimeout(function(){
window.location.href = "anotherpage.html";
}, 3000);
} else {
alert("wrong");
}
}
function neverGunnaRun() {
alert("CHANGE THIS IN EVERY PAGE");
}
1+2 = <input id="inputBox" type="text"> <button onclick="testInput();">Test</button>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
EDIT: Change the "CHANGE THIS IN EVERY PAGE" in the alert function in every different page to something else, and it won't change a thing.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I am working on online shopping website like flipkart and want to forward values through request or say just want to append value to URL, But I have not used form so, I can not use form action. For instance consider following situation.
value1<input type="number" min="1" name="value1">
value1
value2<input type="number" min="1" name="value2">
value2
value3<input type="number" min="1" name="value3">
value3
I have three input text associated with three hyper link and if I hit any link then value in respective text-box should appended to URL and we go to next page.
In this case somePage.jsp?Value=2 something like this....
HTML
<a id="reflectedlink" href="http://www.google.com/search">http://www.google.com/search</a>
I will show you with an example, here on keyup event i am dynamically changing href value.
JAVASCRIPT
<script type="text/javascript">
var link= document.getElementById('reflectedlink');
var input= document.getElementById('searchterm');
input.onchange=input.onkeyup= function() {
link.search= '?q='+encodeURIComponent(input.value);
link.firstChild.data= link.href;
};
Check the same in https://jsfiddle.net/aadi/pr5j9Lbv/
You can change the content of the href attribute via JavaScript, as described here.
thanks André I have got my mistake. the problem is solved by your solution, But I have made mistake is I am given same name for all the links....
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i found this template in themeforest site http://designova.net/reveal/preview/.
i try to explore that template and i found link like this:
http://designova.net/reveal/preview/index.html#filter=.blog%3Anot(.blog2),+.post2
can you tell me about this link params
#filter=.blog%3Anot(.blog2),+.post2
i haven't see link like that before.
This site uses jquery-bbq and jquery-isotope.
With jquery-bbq, it parses the url, and gets a result as a filter.
With jquery-isotope and the filter, it filter items in this site with animation. The mechanism of jquery-isotope is:
Filtering: Hide and reveal item elements easily with jQuery selectors.
When the page loads, JavaScript looks at the value after the hash, then updates the view to that filter. The %3A is encoding for a colon, so the filter value is:
.blog:not(.blog2),+.post2
The .blog is a class selector, so look for all .blog that isn't .blog2 then also show the element with a class name of post2.
Try going to the following URLs and you'll see how the content is different:
http://designova.net/reveal/preview/index.html
Show me everything
http://designova.net/reveal/preview/index.html#filter=.blog
Only show me blog posts (elements with a blog class)
http://designova.net/reveal/preview/index.html#filter=.blog%3Anot(.blog2)
Show me all blog posts with a blog class but exclude those with a blog2 class
http://designova.net/reveal/preview/index.html#filter=.blog%3Anot(.blog2),+.post2
Same as the 3rd link, but also show me the post with the class of post2
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I am trying to make a HTML page list members of a list from a database, I have made the connections already but when using a dropdown to select the name of the list using an onclick, I would like it to display the list members below. I have tried to incorporate an onclick function but it keeps linking to another page when I want it to still stay on the same page but list the members.
<script type="text/javascript">
function changeFunc()
{
var selectBox = document.getElementById("nameoflist");
var selectedValue = selectBox.options[selectBox.selectedIndex].value;
alert(selectedValue);
} </script>
<select name="nameoflist" onchange="changeFunc();">
<option value="" disabled="disabled" selected="selected">Select Recipients</option>
<option value="All Recipients">All Recipients</option>
<option value="Tech List">TechList</option></select>
Look forward to your help!
CP
Save a couple lines, pass in this in your inline handler, and use that in your func:
function changeFunc(obj)
{
var selectedValue = obj.options[obj.selectedIndex].value;
alert(selectedValue);
}
<select name="nameoflist" onchange="changeFunc(this);">