•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the HTML and CSS section within the Web Development category of DaniWeb, a massive community of 374,611 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,491 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our HTML and CSS advertiser: Lunarpages Web Hosting
Views: 4193 | Replies: 7 | Solved
![]() |
•
•
Join Date: Nov 2006
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Could someone please assist me in modifying the following java script code so that it does a word wrap. It currently forms one long long single line.
Thank You ..Tim (I've spent 8 hours trying to solve it...frustrated!)
<p><b>Q10) Breed is not about traits as much as it is about pedigree. Pedigree means?</b><br>
<input type="button" name="submit" value="Answer!" style="FONT-WEIGHT: bold; BACKGROUND: blue; WIDTH: 100px; COLOR: white"
onclick="document.answer.Tim10.value = 'Having papers from the registering body that attest to their ancestry. A tracking registry.';">
<input name=Tim10 rows="2" cols="40" wrap="virtual" style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; WIDTH: 1000px; BORDER-BOTTOM: medium none;color:red">
</p>
</p>
Thank You ..Tim (I've spent 8 hours trying to solve it...frustrated!)
<p><b>Q10) Breed is not about traits as much as it is about pedigree. Pedigree means?</b><br>
<input type="button" name="submit" value="Answer!" style="FONT-WEIGHT: bold; BACKGROUND: blue; WIDTH: 100px; COLOR: white"
onclick="document.answer.Tim10.value = 'Having papers from the registering body that attest to their ancestry. A tracking registry.';">
<input name=Tim10 rows="2" cols="40" wrap="virtual" style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; WIDTH: 1000px; BORDER-BOTTOM: medium none;color:red">
</p>
</p>
Last edited by Tim Stevenson : Nov 25th, 2006 at 7:50 pm. Reason: more information
I'm sorry, I don't mean to sound mean-spirited or sarcastic, but try a JavaScript Forum. Java != JavaScript
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 1,921
Reputation:
Rep Power: 9
Solved Threads: 217
Secondly what you provided is not JavaScript only onClick action which take place on press of submit button. So put one and one together you are trying to steal somebody's work and have no idea what JavaScript is
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Hi there,
Actually the JavaScript is there and its working well, but which Attribute you want to add in textfiels that doesn’t support! With this tag (rows="2" cols="40"), you should use the textarea for this functionality,
[HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="JavaScript" type="text/javascript">
//<![CDATA[
function get_Result()
{
document.answer.Tim10.value = "Having papers from the registering body "+ "\n" +"that attest to their ancestry. A tracking registry.";
document.answer.Tim10a.value = "Having papers from the registering body "+ "\n" +"that attest to their ancestry. A tracking registry.";
document.answer.Tim10.setAttribute("rows","5");
document.answer.Tim10.setAttribute("cols","40");
document.answer.Tim10a.setAttribute("rows","5");
document.answer.Tim10a.setAttribute("cols","40");
}
//]]>
</script>
</head>
<body>
<p><b>Q10) Breed is not about traits as much as it is about pedigree. Pedigree means?</b><br>
<form action="" method="post" name="answer">
<input type="button" name="submit" value="Answer!" onclick="get_Result();" />
<br />
<textarea name="Tim10"></textarea>
<br />
<input name="Tim10a" type="text"/>
</form>
</p>
</body>
</html>
[/HTML]
Regards,
Rahul Dev
Actually the JavaScript is there and its working well, but which Attribute you want to add in textfiels that doesn’t support! With this tag (rows="2" cols="40"), you should use the textarea for this functionality,
[HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="JavaScript" type="text/javascript">
//<![CDATA[
function get_Result()
{
document.answer.Tim10.value = "Having papers from the registering body "+ "\n" +"that attest to their ancestry. A tracking registry.";
document.answer.Tim10a.value = "Having papers from the registering body "+ "\n" +"that attest to their ancestry. A tracking registry.";
document.answer.Tim10.setAttribute("rows","5");
document.answer.Tim10.setAttribute("cols","40");
document.answer.Tim10a.setAttribute("rows","5");
document.answer.Tim10a.setAttribute("cols","40");
}
//]]>
</script>
</head>
<body>
<p><b>Q10) Breed is not about traits as much as it is about pedigree. Pedigree means?</b><br>
<form action="" method="post" name="answer">
<input type="button" name="submit" value="Answer!" onclick="get_Result();" />
<br />
<textarea name="Tim10"></textarea>
<br />
<input name="Tim10a" type="text"/>
</form>
</p>
</body>
</html>
[/HTML]
Regards,
Rahul Dev
Freelance Web Designer & Developer
Http//www.Katarey.com
Http//www.Katarey.com
or you can use the DIV tag to show the Answer!
code is here:
put in head
and this in Body
code is here:
put in head
<script language="JavaScript" type="text/javascript">
//<![CDATA[
function get_Result()
{
var divAnswer = document.getElementById('myDiv');
divAnswer.style.visibility = "visible";
}
//]]>
</script>
<style type="text/css">
<!--
#myDiv {
visibility: hidden;
}
-->
</style>and this in Body
<p><b>Q10) Breed is not about traits as much as it is about pedigree. Pedigree means?</b><br> <form action="" method="post" name="answer"> <input type="button" name="submit" value="Get Answer!" onclick="get_Result();" /> </form> </p> <div id="myDiv"> <p>Having papers from the registering body that attest to their ancestry. A tracking registry.</p> </div>
Freelance Web Designer & Developer
Http//www.Katarey.com
Http//www.Katarey.com
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 1,921
Reputation:
Rep Power: 9
Solved Threads: 217
•
•
•
•
onclick="document.answer.Tim10.value = 'Having papers from the registering body that attest to their ancestry. A tracking registry.';"
IS NOT a JavaScript, it is only action taken once button pressed, which will triget this action. So as it is on its own that code will do nothing
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
•
•
•
•
onclick="document.answer.Tim10.value = 'Having papers from the registering body that attest to their ancestry. A tracking registry.';"
onclick is a event
and "document.answer.Tim10.value" is a JavaScript
syntax : document.FormName.fieldName.value = "The value"
Like in this code I have used the two JavaScript syntax
1.) document.write("Strings")
2.) alert("Strings")
Example 1 :-
[HTML]<input type="submit" name="Submit" value="Submit" onclick="alert('Hello World'),document.write('Hello World')" />[/HTML]
we can write like this
Example 2 :-
[HTML]<input type="submit" name="Submit" value="Submit" onclick="javascript:alert('Hello World'),document.write('Hello World');" />
[/HTML]
or
Example 3 :-
In <head>
[HTML]<script language="JavaScript" type="text/javascript">
/*<![CDATA[*/
function btnClick()
{
alert("Hello World")
document.write("Hello World");
}
/*]]>*/
</script> [/HTML]
in <body>
[HTML]<input type="submit" name="Submit" value="Submit" onclick="btnClick();" />[/HTML]
All three Example will give the same result
Freelance Web Designer & Developer
Http//www.Katarey.com
Http//www.Katarey.com
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 916
Reputation:
Rep Power: 5
Solved Threads: 46
•
•
•
•
[a valid, functional javascript function in an event handler attribute]
IS NOT a JavaScript, it is only action taken once button pressed, which will triget this action. So as it is on its own that code will do nothing
heck, I write huge javascript functions dynamically (on CGI/XSLT pages); directly into onwhatever attributes.
and i've never had any problems.
well that's a lie.
generally lengthly event attributes in HTML should be avoided where possible for managability, but sometimes it's the most simple solution: <body onload="alert({$STATUS});"/> for example, works nicely in XSLT, and the other language I'm using at the moment.
If it only works in Internet Explorer; it doesn't work.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb HTML and CSS Marketplace
- how can i pass a value from java script to JSP scriplet (JSP)
- FireFox config setting through Java Script (Community Introductions)
- How to Embed CheckList Box on HTML Page using Java Script (HTML and CSS)
- A question on java script?(Please answer ASAP) (Java)
- java script for main menu (ASP)
Other Threads in the HTML and CSS Forum
- Previous Thread: Urgent...Having problem with the following HTML code in IE7
- Next Thread: css



Linear Mode