Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

[SOLVED] No attribute name, but id keeps javascript from working

javascript attribute id

  • This topic is locked This topic is locked
3 replies to this topic

#1 RavenStorm

RavenStorm

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 154 posts
  • Location:Ontario, Canada
  • Learning:C, C#, PHP, (Visual) Basic, JavaScript, PL/SQL, Visual Basic .NET, Transact-SQL, Lua, ActionScript, VBScript, Others

Posted 30 October 2012 - 11:31 AM

So I am getting the warning that there is no attribute name allowed in XHTML strict, which I know, but if I use id the javascript will not work. Any ideas I can try?

<h4>Your screen information:</h4>
<table class="infotable">
<tr>
<td><form action="post" name="info">
<table>
<tr>
<td>width:</td>
<td><input type="text" id="info1"/></td>
</tr>
<tr>
<td>height:</td>
<td><input type="text" id="info2"/></td>
</tr>
<tr>
<td>availWidth:</td>
<td><input type="text" id="info5"/></td>
</tr>
<tr>
<td>availHeight:</td>
<td><input type="text" id="info6"/></td>
</tr>
<tr>
<td>colorDepth:</td>
<td><input type="text" id="info3"/></td>
</tr>
<tr>
<td>pixelDepth:</td>
<td><input type="text" id="info4"/></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<script type="text/javascript">
<!--CDATA
function show(){
if (!document.all&&!document.layers&&!document.getElementById)
return
document.info.info1.value=screen.width
document.info.info2.value=screen.height
document.info.info3.value=screen.colorDepth
document.info.info4.value=screen.pixelDepth
document.info.info5.value=screen.availWidth
document.info.info6.value=screen.availHeight
}
show()
//-->
</script>

Edited by Roger, 21 February 2013 - 10:59 AM.

  • 0

#2 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 30 October 2012 - 01:47 PM

Hm, isn't the path document.forms.info.info1?
  • 1

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#3 RavenStorm

RavenStorm

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 154 posts
  • Location:Ontario, Canada
  • Learning:C, C#, PHP, (Visual) Basic, JavaScript, PL/SQL, Visual Basic .NET, Transact-SQL, Lua, ActionScript, VBScript, Others

Posted 30 October 2012 - 01:49 PM

I will try that. The code works, but "name" is not validating. Be right back!

Yes! Thank you Orjan! :thumbup:
  • 0

#4 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 30 October 2012 - 03:51 PM

This topic has been marked as SOLVED. If you have a similar question or topic, you can go back to the subforum and start a new topic to continue discussions.
  • 0

sudo rm -rf / && echo $'Sanitize your inputs!'






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download