Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

span tag length

Status
Not open for further replies.

kristinac13

Programmer
Dec 22, 2005
27
US
Good morning! I have a page with ASP, HTML, and java. In the HTML I have a span tag that brings up a little text box for the user to type in a "reason" for something. I cannot seem to control the length of the text entered in the span. I cannot find any attributes that will prevent the user from entering too many characters. I need to use the span tag for various reasons. Is there any way to tell a span tag to only allow a fixed number of characters to be entered? I've tried maxlength and even some java to set the length but nothing has worked. Any ideas would be appreciated! Thanks!
 
Okay I'm sorry you're right I should have included the code. Okay I have:

<code>
<span id="markar"></span>
</code>

I'm working with someone else's code here, and from what I can tell that single statement pulls up a little text box for the user to enter a comment. If the comment is longer than the text box, the page bombs upon submit. I have determined how many characters my page will accept and I just want to control how many characters are allowed to be entered.

Does that help at all? There really isn't any other code controlling this particular...control. I'm a bit green too so perhaps I'm not giving you the right info. I haven't been here in so long I've forgotten the tag to make the code appear properly in my posts even! So sorry. Please advise. Thanks so much.
 
no. there must be some sort of javascript that's prompting the user for text. as for making the page "bomb" when a user enters too long of a string, that's quite impossible too. there is no limit for span tags.

please give us a link or your code.



*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
Okay I see. And the field that accepts the text from this box and displays it on the page after submit will not accept a string longer than the visual size of the text box. I realize span's don't limit length, but the field that uses this data apparently does. If that makes any sense. Plus the information being entered is something we need to control the length of anyhow.
Here is the java I believe is controlling the text box...

<code>
function setAR(mynumb){
mynumb = mynumb - 1

if(document.all.teamcount.value == 1){
document.all.AR1.value = document.all.AR.value
if(document.all.AR.value == "R"){
y = (prompt("Please enter rejection reason.", "Type reason here"))
}else{
y = ""
}
document.all.ARreason.value = y
if(document.all.AR.value == "L"){
y = (prompt("Please enter alternate reason.", "Type reason here"))
}else{
y = ""
}
document.all.Altreason.value = y

if(document.all.AR.value != document.all.ARold.value){
document.all.markar.innerText = "*"
}else{
document.all.markar.innerText = ""

}

}else{
document.all.AR1[mynumb].value = document.all.AR[mynumb].value
if(document.all.AR[mynumb].value == "R"){
y = (prompt("Please enter rejection reason.", "Type reason here"))
}else{
y = ""
}
document.all.ARreason[mynumb].value = y

if(document.all.AR[mynumb].value == "L"){
y = (prompt("Please enter Alternate reason.", "Type reason here"))
}else{
y = ""
}
document.all.Altreason[mynumb].value = y
if(document.all.AR[mynumb].value != document.all.ARold[mynumb].value){
document.all.markar[mynumb].innerText = "*"
}else{
document.all.markar[mynumb].innerText = ""

}
}

}
</code>

This is the right function I went back and checked. This controls the pop up comment box that I'm trying to handle. So perhaps within this function I can control the length? The person who wrote the original page insists that I must keep the span tag as opposed to something else.

Again I apologize for being so green.

"I don't wanna learn what I'll need to forget!
 
The page is huge. I couldn't possibly ask you to go through all the code. It's ridiculous. And the only instance of "markar" is in the span tag and in the function. Is there any way within the function you looked at to control the length of the string? I really don't know what part of the html to send you and trust me, you don't want me to send the whole page. I wish I could use something other than span, something with a maxlength kind of attribute. I don't know maybe I'm spinning my wheels.

"I don't wanna learn what I'll need to forget!
 
ok, well maybe it has to do with some native CSS. Maybe the original developer set it up so that, if the width of the span exceeded a certain size, it would just hide the rest of the stuff. is there any questionable CSS in your page?



*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
No it does not appear this page is using a CSS. I wonder if it could have anything to do with where the comment is displayed after it is submitted. The string is displayed in a table cell. Perhaps the table cell can't handle the size of the string? Is that even possible? I would think it would just resize to fit like I've seen in the past. I tried to set a CSS class for the span tag at the top of my page, however again I found nothing that would control the length of the string being entered. I'm not giving you much to work with am I? :(

"I don't wanna learn what I'll need to forget!
 
Sorry, perhaps I shoudl be more clear.

Somewhere in the HTML, you will have a form.
That form will have an action attribute which will tell the browser what to do with the data from the form. i.e. it will send it to "formProcessing.asp"

From what I can make out you are saying taht what is put into your form is then being reproduced on another page but truncated.
In which case the truncation is either being done by the processing, by javascript or as my esteemed cFLaVa says, by the CSS simply hiding it.

Foamcow Heavy Industries - Web design and ranting
Buy Languedoc wines in the UK
 
Okay. I get it. Here is the form line:

Code:
<FORM name="myform" action="AssnTrnEntsTEST.asp" method="POST" >

This asp page is the same page the user is on...The information is passed back into the same page and displayed in a table cell. I haven't found a css file yet or any evidence we're using one on this page. The string is passed into an array in ASP when the page submits. Perhaps the array item cannot hold the value? The person who did this page originally named the arrays very strange so I'm still trying to isolate what array and what item I'm trying to work with here.

"I don't wanna learn what I'll need to forget!
 
Somewhere in that form, there WILL be an input element. You CANNOT type information into a span. It's as simple as that.

You need to show the code for the INPUT element that is being typed into. If you do not know which it is, I suggest you ask the person who wrote the page.

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
OK, show us the ASP code in your page that looks like it might be dealing with the form data.

My bet is that there is a string function in there that is truncating the input from the form.

Either that or it's being written to a database and the column for that particular bit of data is set to a limited length or something.

It could be a CSS thing but it's more likely it's ASP or Javascript. My money is on ASP.

Why not post the code for the page here or perhaps in the ASP forum?

Foamcow Heavy Industries - Web design and ranting
Buy Languedoc wines in the UK
 
No wait - it's not being entered in the form at all! It's being entered in the "prompt" statement in your JavaScript.

This being the case, you'd need to ask in the JavaScript forum (forum216) about how to restrict the amount of data you can input using the prompt method.

Of course, you can't really restrict it, simply truncate it, or get the user to enter it again if it's too long.

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Perhaps an event handler function for the form's onSubmit event would be a good place to verify the length of this string?
 
Awesome Dan thank you. I will do that. I realize now what is taking the value. It's:

Code:
<input name="Altreason" type="hidden" value="<%=bret(23,i)%>">

Yes I agree and if it is not a java or asp issue, perhaps it is a database issue, placing the problem firmly in someone else's hands. lol! I will post to javascript forum and see what I find out. Thank you so much for all your help.

"I don't wanna learn what I'll need to forget!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top