JavaScript - Make Text Bold
Hello, I wonder if you guys.girls would be kind enough to help me. I have some code, but I need to make the " Total price will be :$xx " text to be in bold.
Here is the code I have atm Code: <script type=text/javascript> function getTotal(){ var form=document.theForm; var inputs=form.getElementsByTagName('input'); var length=inputs.length; var total='0'; for(i=0;i<length-1;i++){ if(inputs[i].type=='radio'){ var checked=inputs[i].checked?1:0; if(checked){ var value=inputs[i].value.split("~~")[0]; total-=-value; } } } document.getElementById('totalspan').innerHTML="Total price will be: $"+total total='0'; } </script> </html> Similar Tutorialshi, i am trying to make my website so that when i click on a button it makes the selected text into bold or when i click another button it makes the selected text italic and finally when a thrid button is clicked it makes it underlined. i have tried searching for a way of doing this throught javascript but i cant seem to find any. any suggestions or examples on how i can achieve this would be much appreciated as i really need to get this working, thanks for any advice given -------------------------------------------------------------------------------- Can some1 help me at this, i am very new to javsciprt and HTML things, so as the title says, a simple bold to the selected text in a div is what i need. below is the div area i have, so how do it?? Code: <TD colspan="25" width="525px" style="text-overflow: ellipsis; overflow: hidden;"> <input type="hidden" $acmForms.bindText("casecomments") /> <div #if (!$acmForms.getFormAttributes().isReadOnly()) CONTENTEDITABLE #end onKeyUp="dairy_limitTextArea(this, 4000)" onKeyDown="dairy_limitTextArea(this, 4000)" id="spell_casecomments" style="width:800px; height:220px; overflow: auto; border: 1px solid #bdcee5;"> </TD> hey im new to javascript and im working in this function , i can't get it work here is my code PHP Code: <SCRIPT LANGUAGE="JavaScript"> function text(form1) { var j = document.form1.diary.value; j = j.italics(); document.form1.diary.value = j ; } </SCRIPT> whats the problem ? Hello. I have created a Bold button - when i click the button it applies it into my textarea. The Problem is if i want to apply the bold style only to a single line and the rest of the written text will be normal and not bold it doesn't work. How can I add to the function that when i select a certain line and click on the button to make it bold only the selected line will be bold?? This is the script : PHP Code: <script type="text/javascript"> function bold(id) { var element = document.getElementById(id); element.style.fontWeight = ( element.style.fontWeight == "bold" ) ? "normal" : "bold"; } </script> And this is the button : PHP Code: <img src="Bold.bmp"width="42" height="39" title="Bold Font" onclick="bold('bodytext')" style="cursor:pointer;" /> Hello guys! Subject is not clear, but I will have it as clear as I can! First, I am totally new to the JS! I have some skills but not too much! here is a code: PHP Code: <? include('func.php'); ?> <html> <head> <script language="JavaScript" type="text/javascript"> function editfield(u){ var user = document.getElementById(user); } </script> </head> <body> <table border="1"> <tr> <td> username </td> </tr> <? while ($row = mysql_fetch_array($SQL)) { echo '<tr>'; echo '<td name="user" onDblcilck="editfield()">' . $row['username'] . '</td>'; echo '</tr>'; } // HOWEVER! I need to edit $row['username']. So, on double click i need it to change to <input type="text" /> field! // And then I need to get that variable of the edited username, and submitted it through a form to the db! ?> </table> </body> </html> I need when dblclick to convert the <td> to <input />! And I want to get the value of the edited user to submitted to the database! Hello All, I have made a prompt and marked it in bold below. I would like text to appear after what the person has entered At current it reads Hello (Name Prompt) I would like it to appear saying something on the lines of Hello (Name Prompt) Enjoy The Game. Any Ideas? <html> <body> <SCRIPT LANGUAGE="JavaScript"> <head> <TITLE>Find the Correct Number Game</TITLE> </head> a=(prompt('please enter your name:',0)); // prompt for player name document.write(' Hello ' ,a); var guessme=Math.round(Math.random()*(49)+1); var speech='Choose a number between 1 and 50'; function process(hiddennumber) { var guessnumber=document.forms.guesstable.guessnumber.value; var speech='"'+guessnumber+ '" Letters are not allowed. Please enter digits only!.'; document.forms.guesstable.guessnumber.value=''; if (guessnumber==hiddennumber) { document.forms.guesstable.prompt.value='Congratulations! '+hiddennumber+' is correct!'; alert ('Well done - the mystery number is '+hiddennumber+'! \n\nIf you want to play again click the button.'); speech=''; document.location=document.location; } if (hiddennumber<guessnumber) { speech='Less than '+ guessnumber; } if (hiddennumber>guessnumber) { speech='Greater than '+ guessnumber; } if (guessnumber=='') { speech='You didn\'t guess anything!' } document.forms.guesstable.prompt.value=speech; document.forms.guesstable.guessnumber.focus(); } </SCRIPT> </body> </html> <FORM onSubmit="" NAME="guesstable"> <CENTER> <TABLE ALIGN="left" BGCOLOR="#888889" BORDER="5" CELLPADDING="5"> <TR> <TD BGCOLOR="#004081"> <FONT COLOR="#ffffff" FACE="Arial"><B>Find the Correct Number</B></FONT> </TD> </TR> <TR> <TD> <CENTER> <INPUT TYPE="text" NAME="prompt" SIZE="31" MAXLENGTH="60" VALUE="Find the correct number which is between 1 and 50"><BR> <INPUT TYPE="text" NAME="guessnumber" SIZE="3" MAXLENGTH="3" VALUE=""> <INPUT TYPE="button" VALUE="Enter" onClick='process(guessme)'> </CENTER> </TD> </TR> </TABLE> </CENTER> </FORM> I have a document list of several hundred drug names where some are lower case and some are all caps. I want to bold only the lower case drug names but don't want to do it manually. Is there a java script that I can apply where it automatically does that for me?
Hi, I found the following code on a web site. It displays text as if it were being typed but it only does it once. I have been trying to use various functions to make the effect continuous, i.e. make the header appear as typing text, clear the text, again make the header appear as typing text, clear the text, and so on. I wish this to continue for as long as the web page is open. But I just can't get it to work. I wonder if anyone has any suggestions? I would be very grateful for all help. [code] <h2 id="fly">Header</h2> <script type="text/javascript"> //Use "$" for linebreak //By default, set to just grab the text from element with ID="fly" message = document.getElementById("fly").innerHTML; // $ = taking a new line distance = 50; // pixel(s) speed = 200; // milliseconds var txt="", num=0, num4=0, flyofle="", flyofwi="", flyofto="", fly=document.getElementById("fly"); function stfly() { for(i=0;i != message.length;i++) { if(message.charAt(i) != "$") txt += "<span style='position:relative;visibility:hidden;' id='n"+i+"'>"+message.charAt(i)+"<\/span>"; else txt += "<br>"; } fly.innerHTML = txt; txt = ""; flyofle = fly.offsetLeft; flyofwi = fly.offsetWidth; flyofto = fly.offsetTop; fly2b(); } function fly2b() { if(num4 != message.length) { if(message.charAt(num4) != "$") { var then = document.getElementById("n" + num4); then.style.left = flyofle - then.offsetLeft + flyofwi / 2; then.style.top = flyofto - then.offsetTop + distance; fly3(then.id, parseInt(then.style.left), parseInt(then.style.left) / 5, parseInt(then.style.top), parseInt(then.style.top) / 5); } num4++; setTimeout("fly2b()", speed); } } function fly3(target,lef2,num2,top2,num3) { if((Math.floor(top2) != 0 && Math.floor(top2) != -1) || (Math.floor(lef2) != 0 && Math.floor(lef2) != -1)) { if(lef2 >= 0) lef2 -= num2; else lef2 += num2 * -1; if(Math.floor(lef2) != -1) { document.getElementById(target).style.visibility = "visible"; document.getElementById(target).style.left = Math.floor(lef2); } else { document.getElementById(target).style.visibility = "visible"; document.getElementById(target).style.left = Math.floor(lef2 + 1); } if(lef2 >= 0) top2 -= num3 else top2 += num3 * -1; if(Math.floor(top2) != -1) document.getElementById(target).style.top = Math.floor(top2); else document.getElementById(target).style.top = Math.floor(top2 + 1); setTimeout("fly3('"+target+"',"+lef2+","+num2+","+top2+","+num3+")",50) } } stfly() </script> [code] Ok, so i got two buttons made with css, that i want to link to two different text that will appear in a <div> when i press them. Quote: <a href="#" class="title4"value="Click" onclick="document.getElementById('introduktion').innerHTML=''"/> Introduktion </a> <a href=".pdf" class="title4" > CV </a> <a href="#" class="title5"value="Click" onclick="then var name =.innerHTML;document.getElementById('presentation').innerHTML=''"/ >Presentation </a> </div> <div class="post"> <div class="text" style="; height:387px; width:400px; overflow:auto;"> <br> <span id="introduktion" href="#"> <font size="2"> text 1 </span> <span id="presentation" href="#">text 2 </span> The button works, but when i press them more than once everything disappears... Do anyone have any idea on how to solve this problem? Hi there, I would like to do the following: When I click on a button, it will set the item in the listbox to be bold. But this will only happen when the user clicks on the desired item to be bold and presses the button. An alert message will occur when he/she presses the button without clicking on the item, stating that the user will need to click on the item. How shoukld I do it in javascript? Here is my validation script from dreamweaver i also have it in php for server side. But I trying to get a checkbox to make a text field required when you select it. Right now I have it so when you hit submit whether the text field is filled out or whether the checkbox is selected or not the error message comes up no matter what i do please help. the link to the page is http://www.mark-10.com/inquiries2 Code: function validateCheckbox() { if(document.forms["form1"].sales.checked) { if(document.forms["form1"].telephone.value.length < 12) { // xxx-xxx-xxxx return false ; } else { return true; } } } function MM_validateForm() { //v4.0 if (document.getElementById){ var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]); if (val) { nm=val.name; if ((val=val.value)!="") { if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n'; } else if (test!='R') { num = parseFloat(val); if (isNaN(val)) errors+='- '+nm+' must contain a number.\n'; if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n'; } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; } } if(!validateCheckbox()) { errors+="If checkbox checked, please include telephone number"; } if (errors) alert('The following error(s) occurred:\n'+errors); document.MM_returnValue = (errors == ''); } } //--> Dear All, Here I am facing one issue, that I want to removing all html tags except BOLD,ITALIC,UNDERLINE & UL,LI. Means if my data is like, <b><i> Test Data </b></i> <input type="text" name="test"> <script> function test() { ............. } </script> Then I want the following output.... <b><i> Test Data </b></i> function test() { ............. } Means I need the data with tags BOLD,ITALIC,UNDERLINE & UL,LI not any else tags..... I have tried with this strInputCode.replace(/<[^>]+>/ig,""); but its removing all html tas that i dont want Hello, I'm learning javascript, and was wondering if it was Possible to have buttons/links that you click, the whole page fades out, and then fade's in, with different stuff. here are my ideas for just changing the stuff Text: 1. having a javascript src file to start, and then when the button is clicked, that is formatted to white, the text layer is moved down, and a new javascript file is loaded? 2.variables? any help would be appreciated! Thanks, Cookies, whatever this forum gives out, you may receive! As of right now I have a code that will work in IE but wont work in FireFox...go figure. Basically what I want to have happen is when you type in an area code it will provide an output in a predetermined area of the page. For Example: Input- 512 Output - Austin, TX The code that I have doesn't work with firefox and I was just wondering if there was a code that would allow that to happen. Thanks! Hi, I have a form with 9 text fields and a text area. What I want to do is replace the text in the text area depending on how many fields contain text. For example my text boxes are named 1 to 9, if the user enters text in the first five boxes I want the text area to auto fill with 'you have selected boxes 1 to 5' if the user selects all nine it will say 'you have selected 1 to 9', therefore, the user must complete the text boxes in order. I have it working with an onchange event but i have a button on the form to also auto fill the text boxes and it does not work if this is clicked. Any help would be appreciated! Hi all, Thanks for reading. I'm having an issue trying to accomplish the following - I have a text field (field1) already displayed on the HTML page. However, there's a link where you can add additional text fields to the page as well. When the link is clicked, the second text field is added successfully (field2), and when the link is clicked again, the third text field (field3) is added successfully. However, the third field does not add itself to the page, and the text for anything greater than a third field also isn't displayed after. This obviously means that my "fields" variable is not working right, so I'm wondering, would anyone be able to assist me to help me get that variable processing correctly? Code: <script language="javascript"> fields = 1; function addMore() { if (fields = 1) { document.getElementById('addedMore').innerHTML = "<input type='text' name='field2' size='25' /> <span>Field 2.</span>"; fields = 2; } else if (fields = 2) { document.getElementById('addedMore').innerHTML = "<input type='text' name='field3' size='25' /> <span>Field 3.</span>"; fields = 3; } else { document.getElementById('addedMore').innerHTML = "Only 3 fields are allowed."; document.form.add.disabled=true; } } </script> Here is the code in my HTML - Code: <input type="text" name="field1" size="25" /> <span>Field 1.</span> <div id="addedMore"></div> <p class="addMore"><form name="add"><a onclick="addMore()">Add another field.</a></form></p> Thank you very much. Hello. I have a textarea where user can select a text then copy to clipboard (using EditArea script for highlighting) I need append additional information to the selected text so it won't be visible in the textarea, but only appear after copied to clipboard. For example: Code: text line one text line two text line three user selected word "two", hit CTRL+C to copy into clipboard (or used browser's context menu), but in clipboard it should be saved as: "selected word 'two'" What would be the approach? Thank you. Hi, I have a form setup so that selecting a radio button opens a specific text field. The problem is if the user starts to enter information, then switches to a different radio button (perhaps they chose the wrong radio to start), the text they already started to enter on the previous textfield doesn't get cleared. This will be a problem later when inserting to sql. Here is a summary of the code: Code: <head> <script type="text/javascript"> function doClick(objRad){ if (objRad.value=="0"){ document.getElementById("textbox").style.display='block'; } else{ document.getElementById("textbox").style.display='none'; } if (objRad.value=="1"){ document.getElementById("textbox1").style.display='block'; } else{ document.getElementById("textbox1").style.display='none'; } if (objRad.value=="2"){ document.getElementById("textbox2").style.display='block'; } else{ document.getElementById("textbox2").style.display='none'; } } </script> </head> <body> <form action="insert.php" method="post"> <p>Please choose the business type: <input type="radio" name="rad" value="0" onclick="doClick(this)"> Sole Proprietorship <input type="radio" name="rad" value="1" onclick="doClick(this)"> Partnership <input type="radio" name="rad" value="2" onclick="doClick(this)"> Corporation <div id="textbox" style="display:none"> <input type="text" name="txt"> This is my sole proprietorship info.</div> <div id="textbox1" style="display:none"> <input type="text" name="txt"> This is my partnership info.</div> <div id="textbox2" style="display:none"> <input type="text" name="txt">This is my corporation info. </div> </form> </body> Any help is appreciated, Thanks in advance! im clueless when it comes to javascript, but this is what im trying to find: i have a page that has multiple text areas, i also have 4 links that when clicked i want to add some predefined text into the active text area the one with the text cursor in? The Hyperlinks: Code: <a href="#sc">Shift Changed</a> | <a href="#ol">On Leave</a> | <a href="#ot">OverTime</a> | <a href="#ss">ShiftSwap</a> The textareas: PHP Code: <td><textarea name=details$i rows=4 align=absmiddle cols=16 value="$details[$i]\">$details[$i]</textarea></td> as you can see the textareas are created on the fly based on a php array. would anyone be willing to put some code together for this? or even give me the basics on how i can get the active textarea's name so i can pass that to a script that inserts into a given field? Hi. I have developed a form all working fine but am struggling on the following. I need a checkbox for an item, when the checkbox is true the user can enter text in a text box, only if the checkbox is ticked. I have numerous items I need for this. Hope someone can help. Thanks |