Change Text Within Paragraph Depending On Radio Button?

Mar 23, 2011

I have an electronics site on which I have a code generator. Im an stuck on how to acheive something.

I will simplify what I want to do, so I can then adapt it to my code. I have a paragraph of text on the web page, on which I want to change some words with in the paragraph depending on 2 radio buttons.

Example (radio buttons & short paragraph):

(Radio Button) Apples (checked) (Radio Button) Bananas "Welcome to jakes fruit shop. You have selected apples today" (apples being the word that would change if the banana radio button is checked)

Here is the code generator if your interested. [URL] What I actually want to do is put other 'fixed' text in the input text area (near botton of page) with only the config line changing.

And If I can be shown how to do the short example above, i think I will be able to edit my generator and get it to do what i want it to do.

View 6 Replies


ADVERTISEMENT

JQuery :: Getting Radio Button Changes Some Paragraph Text

Dec 11, 2010

I have code that initially sets a radio button and then changes some paragraph text based on the value of the radio button. After this initial setting, I want the user to be able to change the radio buttons and get changes to the paragraph text. Currently, the code allows a change to the radio button and it shows on the screen, but the value does not change so the paragraph text does not change. I tracked this down by looking at alerts. How do I get the click on the radio button to register a change in the radio button value in jQuery? Here's the simplified code.

$(function() {
//Initialize country
$('input[name="country"]:first').attr('checked', 'checked'); //Set first radio button (United States)
alert('|' + $('input[name="country"]').attr("selected", true).val() + '|1st');
//Enable changes to the country selection and change page text as the selections change
$('input[name="country"]').change(function ()
// change the page per this logic
switch ($('input[name="country"]').attr("selected",true).val()) {
case 'United_States':
alert('|' + $('input[name="country"]').attr("selected", true).val() + '|3rd');
$('#stateMessage').text('Select a state or territory of the United States.'); break;
case 'Canada':
alert('|' + $('input[name="country"]').attr("selected", true).val() + '|4th');
$('#stateMessage').text('Select a province or territory of Canada.'); break;
default:
$('#stateMessage').text('Test - all other');
};
}).change(); // not clear what this change() does. Its in a jQuery example, but code works w or w/o it.
// Autocomplete jQuery code here which works
});
<p><label for="country">1. Click a country: </label>
<input type="radio" id="unitedStates" name="country" value="United_States">United States
<input type="radio" id="canada" name="country" value="Canada">Canada</p
<p id="stateMessage"> 2. This text should change as radio buttons change.</p>

View 3 Replies View Related

Dynamically Change Text In A Radio Button

Oct 12, 2007

I'm trying to write a Javascript quiz. The idea being that each question has 4 possible answers. The answers being in the form of multiple choice radio button. Instead of having either a long list of radio buttons and questions or loads of pages with tons of duplicated code, I'd like to make the quiz as one page. Pulling the questions, and possible answers from an array. All this I can do, except for changing the text on the radio buttons. In the past I've used.. getElementById with regular text to good effect, but can't manage it with the radio button. Here is part of my test code..

[Code]...

View 11 Replies View Related

Clicked Radio Button Text To Change Colour

Mar 3, 2005

i made a quiz using radio buttons and ofcourse javascript,but to further customized my quiz i want an event handler in which it will change the text color attached to a particular radio button when the user clicks an option.

View 1 Replies View Related

Change The Background Colour If A Paragraph On Click On That Paragraph?

Jan 9, 2011

I am trying to change the background of a paragraph when the text on that paragraph is clicked.

The code looks like:

p= document.createElement("p");
p.onclick = function(){ p.setAttribute("style","background:#306EFF; " ) ; } ;

However it will not work.

What changes should I do in order to make it work?

View 3 Replies View Related

Change Displayed Text In Paragraph Without Reloading Page?

Dec 6, 2011

I have a list of paragraphs that all need to say the same thing. Each has it's own ID and class (each one has a different font color) and I need a co-worker to be able to type a phrase or name into a form field & hit "go" and have it update all of the paragraphs to reflect that text in the various colors. I also need it to have a predetermined default phrase.

Example:
Welcome Home (in blue)
Welcome Home (in red)
Welcome Home (in green)
Welcome Home (in black)
Welcome Home (in yellow) etc.

I already have the framework set up (with the colors and everything) it's just a matter of changing the contents of the paragraph-tag.

View 3 Replies View Related

Toggle Color Depending On Whether A Radio Button Is Selected Or Deselected

Feb 15, 2007

I have an online application used for grading students. On one of the
pages, I have a table with two rows and each row has 16 cells. The
upper row contains the letter grade (A, A-, B+, B, etc) and the lower
row has a 16 radio buttons for selecting the appropriate grade. This
all writes to a SQL server back-end and has been working fine for
several semesters. Some faculty members have complained that it is
hard to read and see which have been graded so far and which still
need to be graded. It has been suggested that we change the
background color of the selected letter grade to a different color. I
have had some sucess with this, but haven't figured out how to
"toggle" the color on and off based on the state of the radio button.
I can get it to change color when selected, but the color persists if
another radio button is selected. Does anyone have some sample code
for this?

View 2 Replies View Related

JQuery :: Update A Shopcart Depending On Radio Button Choice?

Jun 28, 2011

I'm trying to update a shopcart depending on radio button choice, the problem is when I'm submitting and want to go to the next page.

Imagine this, I'm on a page with 2 radio buttons, either u can pick A or B, depending on my choice the shopcart gets updated, and its placed in the bottom of the page, to that point everything works fine.But when I post from my form and get redirected to the next page it seems like my jquery function runs again and choose the first radio button even if i have the second selected when posting.$cart is the class object and i add the items with just a name and some price parameters.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {[code]....

View 2 Replies View Related

Show / Hide Form Fields Depending On Radio Button Selection

May 29, 2005

How to show and hide form fields depending on a selected radio button.

View 14 Replies View Related

JQuery :: AddClass - Change The Color Of Surrounding Text Of The Disabled Radio Button To The Color Grey

Feb 8, 2010

I have this markup:

[Code]...

There are two radio buttons, sometimes one will be disabled, other times the other will be disabled. I would like to make a script that: First: Changes the color of surrounding text of the disabled radio button to the color grey. Second: Checks the other radio button.

This was my plan: I would make a script that: First: Removes all the current classes and add the class "greyed_out" (or better: change only the color of) the parent element, all siblings and children of siblings (if any) of the radio button that is disabled at that time.Second: Sets the attribute "checked to the other radio button". I made a script, but when I set the bottom radio button to disabled the script doesn't work:

[Code]...

View 4 Replies View Related

JQuery :: Toggle Images Of A Button Depending On A Check Box Change?

Jul 28, 2011

ho do itoggle images of a button depending on a check box changep.s. toggle images of a button these are images now depending on check box clicked the image button should show the enabled image.

View 1 Replies View Related

Change Text Depending On Condition?

Mar 10, 2009

I have the following code that I use to loop though records in my database and display the text. For each record I look through the text for a certain piece of text and then split the content it is found. So for example if the database contained a field with the data "this is some text [splithere] this is some more text" then the first part (this is some text) would be displayed and then a more button would be shown. If the user clicked the more button then the rest of the content (this is some more text) would also be shown.

At the moment the more button is always shown, even if the [splithere] text was not found. What I'd like to do is only show the more button where necessary. I'd also like to change the text from 'more' to 'hide' when the button has been clicked and the additional content is being shown as when they click the link again the text is in fact hidden and so saying 'more' doesn't make any sense.

Here is the code I use code...

View 14 Replies View Related

Set Button Width Depending On The Length Of Text Value?

Jan 11, 2010

I have button with no width specified. The text value of the button differs, so i left it with no width.

It automatically sets the width but the problem is it to wide with about 5 spaces on each side of text letting the button look stupid.

I thought of working out the Text in a javascript function then set the length of the button.

<input id="{Description}" type="button" value="{Description}" onclick="{@name}.click(); style="background-color: #f9f9f9; height: 23px;"></input>

View 2 Replies View Related

JQuery :: Radio Button On Change?

Oct 28, 2011

I have 2 radio buttons.. when i select radio button need to hide div..

Here is my code

[Code]...

View 2 Replies View Related

Resolved Change Radio Button Value

Nov 25, 2010

I want to change radio button values dependent on the selected item in a drop down list.The radio buttons have default values but I need them to be changed when the selection has been made in the drop down list and before the submit button has been pressed so the changed values will be written to the database.

View 2 Replies View Related

Using Radio Button To Change Another Input Value

Mar 9, 2011

I'm trying to use an onclick function in a radio button to change the value of a hidden input in another form. What I want to happen is, when the user changes the value of the radio button (0 or 1), the value of the input named 'repeat' is set to 0 or 1 accordingly. The goal being that when I submit the form with input name='repeat' it will send the number indicated by the radio button.(Due to the structure of my page the radio button and the hidden input need to be two separate forms.

View 1 Replies View Related

Change Radio Button Value From Textbox Value

Mar 11, 2011

I Should have the textbox value as my radio button value. For example, if I type "5" in the textbox, then the radio button value would change to "5". by the way I have three radio buttons and one textbox and if I select one of those and type something in the text box the value would replace to radio button which is selected and all this have to happen before the page submitted or in the process of submitting. I hope I could find answers here (It's so important for me to solve this problem, For see the form please go to this page URL..., Its above the news frame where you can see three radio buttons and one textbox named shipment tracking.

View 12 Replies View Related

Radio Button Onclick Change Url?

Nov 20, 2009

I have a radiobutton set of 2 radiobuttons... I want to be able to change url if the radiobuttons are checked. How do I go about that.I have figured out that I need to use the onClick handler, but cant firgure out how to change the url..

View 2 Replies View Related

JQuery :: Change Img On Toggle Radio Button?

Mar 8, 2010

I wanted to modify an img src tag with a radio button. I tried the following below, with no luck.Not sure I'm doing it right.

[Code]...

View 6 Replies View Related

Radio Button To Change Drop Down Menu?

Oct 12, 2007

Lets say you have a group of radio buttons with values of A, B, and C

I want to have a drop down box, on the same page that the values are changed by which radio button is selected

so if radio value A is selected then the drop down will have values of f1, x2, i3 if radio value B is selected then drop down will have values m1, r4, g3 and so on and so forth.

View 14 Replies View Related

Change Div Background When Radio Button Is Checked

Jan 21, 2010

Pleas how can i change div bg color with active chcecked radio button [code]if checked, change color from #fff to #ccc [code]

View 6 Replies View Related

JQuery :: Change Form On Click Of Appropriate Radio Button

Nov 3, 2011

I am new to jQuery. I want to change the form on click of the appropriate radio button.

This is my code
<s:radio name="radioButton" list="#{'os':'OS','platform':'Platform''}" value="1" />
<div id="OS_req">
<s:form name="sendreqOS" action="Login" ><br/>
<s:textfield name="vmNameOS" maxlength="30" size="20" label="VM Name" />
<s:select labelposition="left" label="Template" list="temp" name="templateNameOS"/>
<s:select labelposition="left" label="Instance Type" name="instanceTypeOS" list="#{'1':'Small','2':'Medium','3':'Large'}" />
<s:select label="Duration of use" name="durationOS" list="#
{'1':'1 week','2':'2 weeks','3':'1 month','4':'3 months','5':'6 months'}" />
<s:submit value="Submit"></s:submit>
</s:form></div>
<div id="Plat_req">
<s:form name="sendreqPlat" action="Login" ><br/>

<s:textfield name="vmNamePlat" maxlength="30" size="20" label="VM Name" />
<s:select labelposition="left" label="Template" list="temp" name="templateNameplat"/>
<s:select labelposition="left" label="Instance Type" name="instanceTypeplat" list="#{'1':'Small','2':'Medium','3':'Large'}" />
<s:select label="Duration of use" name="duration plat" list="#{'1':'1 week','2':'2 weeks','3':'1 month','4':'3 months','5':'6 months'}" />
<s:submit value="Submit"></s:submit></form></div>

On clicking 'OS' radio button I want to get the 1st form and hide second one and on clicking 'Platform' radio button I want the second form and hide the first one.

View 13 Replies View Related

Background Color Of Table Change With Radio Button

Mar 27, 2006

I'm trying to create a cell in a table which changes color depending which radio button is checked.

I found the following code which works for different cells but it doesn't work when the buttons are in the same cell. Think you'll see what i mean. I'm not too hot when it comes to Javascript though so i don't know how to adapt what I've got so far. Code:

View 3 Replies View Related

Radio Button That Prints Text To A Text Box?

Nov 11, 2010

I'm working on an html assignment using javascript and I need to have two radio buttons as well as a text box. When you click on one of the radio buttons it needs to display text inside the text box. right now I have:

Code:
<form>
<input type="radio" name="yes" value="" onclick =" "/> yes</br>

[code]....

View 14 Replies View Related

Change A Label At Page Load Based On Radio Button

Mar 2, 2010

I have a webpage which has two radio buttons. There is a label also in the web page. I want the label string to be based on the radio button status. I am able to change when somebody press the radio button using "onclick" function, but now when the page is reloaded.

Here is my code

Code:

I want the highlighted label value to be changed based on the radio button value at the start up itself( ie if the page get reloaded if some error has happend at filling the form)

View 2 Replies View Related

JQuery :: Pass Radio Button Selection To Hidden Div And Then Show Div List From Chosen Radio Button?

Mar 16, 2010

I am a PHP programmer and new to Javascript and jQuery and I have tried about 20 examples/tutorials and cannot seem to get even close to what I want.I have a form (PHP/MySQL) with a list of subjects I got from my database, and then create a set of radio buttons from that list. And based on what radio button they select, I need to pass that variable to a div (at least that's what I want to use) and then show a list of videos that match the radio buttons value. I don't care if its a get or post or other.I tried to use GET or POST so I can use that value for my PHP/MySQL lists.I am open to any suggestions/tutorials, etc.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved