×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Apr 2007
    Location
    Malaysia
    Posts
    4

    XHTML+ECMAScript Onclick Change Colour code review

    Hi, I am doing a research on mobile XHTML + ECMA Script, i am currently trying to develop a table with links and when the viewer clicks on that link the colour will change, here is the view of the code.
    However for some reason it doesnt work on the mobile, your feedback and help in helping me to develop this is really appreciated.

    Code Review:
    ?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>javascript test</title>
    </head>

    <script type="text/ecmascript">

    function choice(seatnum,cntnum)
    {
    var strtd = eval("td"+cntnum);
    schk = eval("document.sform.hs"+cntnum);

    if (schk.value == "F") {
    schk.value = "S";
    strtd.style.backgroundColor = "#95FF95"; //select
    }
    else {
    schk.value = "F";
    strtd.style.backgroundColor = "#8080FF"; //free
    }
    return false;
    }

    </script>

    <body>

    <form name="sform" action="#" onsubmit="return checkSubmit();">
    <table border="0" cellspacing="1" cellpadding="1">
    <tr>
    <td id="td1" style="background-color: #8080FF">
    <a href="#" onclick="return choice('S1','1');">1</a><input type="hidden" name="hs1" value="F"/>
    </td>
    <td id="td2" style="background-color: #8080FF">
    <a href="#" onclick="return choice('S2','2');">2</a><input type="hidden" name="hs2" value="F"/>
    </td>
    <td id="td3" style="background-color: #8080FF">
    <a href="#" onclick="return choice('S3','3');">3</a><input type="hidden" name="hs3" value="F"/>
    </td>
    </tr>
    </table>
    </form>

    </body>
    </html>

  2. #2
    Registered User
    Join Date
    Apr 2007
    Posts
    4

    Re: XHTML+ECMAScript Onclick Change Colour code review

    Hi, I don´t Know the answer, but i have the same problem

    What mobile browser simulator are u using?? I tried whit NMBS 4.0 and it dont run, and reading the content type soported, Ecma Script dont appear, so i figure i cant test my Ecma Script aplications on that Simulator.

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    9

    Re: XHTML+ECMAScript Onclick Change Colour code review

    I hope the following link can guide you in your problem
    CSS Mobile Profile 2.0
    http://www.w3.org/TR/css-mobile/

  4. #4
    Registered User
    Join Date
    Apr 2007
    Location
    Malaysia
    Posts
    4

    Re: XHTML+ECMAScript Onclick Change Colour code review

    Thanks for the link bellskar, i will look into it,
    I actually use mobile phones to test my application, i found out that most simulators doesnt display as what it displays on mobile phones.
    now i tried to do mapping and onclick it changes color but ofcourse it has to submit the page, however still researching the ecma script.

    Regards,
    Danial Simmonds
    Sincerely,
    Danial Adam Simmonds

    - The future of mobile technology is in your hands -

  5. #5
    Registered User
    Join Date
    May 2007
    Posts
    1

    Re: XHTML+ECMAScript Onclick Change Colour code review

    HI,

    Am new to XHTML and ECMAScript.Tested the sample code above in the N40 SDK 3rd edition.I think the "eval" function in Ecmascript is not executing. i,e if i give alert(eval("td")); at the first line of the EcmaScript its not executing that statement.If you get any answer for this then please replay.

  6. #6
    Registered User
    Join Date
    Aug 2007
    Posts
    6

    Re: XHTML+ECMAScript Onclick Change Colour code review

    Me too. I also have same question. i want to display the content on the same area. But it can't work.
    ...................................
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>New HTML Document</title>
    <script type="text/ecmascript">
    function Compute()
    {
    var string;

    string="<table><tr><td>"+Math.random()+"</td></tr></table>";

    document.getElementById("display").innerHTML=string;
    }
    </script>
    </head>
    <body>

    <form name="form1" action="" method="post" >
    <div id="display" > you; </div>
    <input type="button" name="Submit" value="submt" onClick="Compute()">
    </form>
    </body>
    </html>
    ..........................................................................................
    Thanks a lot.

Similar Threads

  1. How Change the text colour in Phonebook
    By pepe79 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2005-06-21, 13:23
  2. change MIDI intrument by j2me code
    By sangzz in forum Mobile Java General
    Replies: 3
    Last Post: 2005-05-04, 04:48
  3. How to Change input mode to "123" in XHTML
    By daytai in forum Browsing and Mark-ups
    Replies: 3
    Last Post: 2004-06-08, 17:09
  4. change code optimization in cpp source file for gcc
    By MiKeL in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2003-12-17, 16:55
  5. Can you change the profile from some code
    By Blkangel in forum Symbian
    Replies: 4
    Last Post: 2003-10-30, 17:51

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×