javascript - how to load an another html file on a button click in jquery mobile - Stack Overflow

I am creating an application in phonegap using the jQuery mobile framework.In my index.html file I have

I am creating an application in phonegap using the jQuery mobile framework.

In my index.html file I have a two text boxes to accept username and password.

When I click on the submit button it calls a function submitBtn() that checks whether the username and password is correct or not and if it is correct then it should load a new html file that I have created `selectOption.html'

here is my code

<script type="text/javascript">
    $(document).ready(function() {
        var userName;
        var userPassword;

        $("#submitBtn").click(function() {
            //alert("HI");       
            userName = $("#UserName").val();
            userPassword = $("#Password").val();

            if ((!UserName)|| (!userPassword)) {
                alert("Enter the Details");
            }
            else {
                if ((userName !="alpha") ||(userPassword !="beta")) {
                    alert('Enter correct username and password');
                }
                else {
                    //here i want to load my selectOption.html file ?
                }              
            }                                   
        });                           
    });
</script>

my code under <body> is

<body>
    <div data-role="page" id="home">         
        <div data-role="header">             
            <h1>Enter Credential</h1>                       
        </div>

        <div data-role="content">
            <label for="UserName">User Name</label>
            <input type="text" name="UserName" id="UserName" value="" style="width:220px;"  />

            <label for="Password">Password</label>
            <input type="password" name="Password" id="Password" value="" style="width:220px;"  />

            <div id="submitBtn" data-role="button">Submit</div>
        </div>  
    </div>
</body>

The function is getting called but how can I load the selectOption.html file?

I am creating an application in phonegap using the jQuery mobile framework.

In my index.html file I have a two text boxes to accept username and password.

When I click on the submit button it calls a function submitBtn() that checks whether the username and password is correct or not and if it is correct then it should load a new html file that I have created `selectOption.html'

here is my code

<script type="text/javascript">
    $(document).ready(function() {
        var userName;
        var userPassword;

        $("#submitBtn").click(function() {
            //alert("HI");       
            userName = $("#UserName").val();
            userPassword = $("#Password").val();

            if ((!UserName)|| (!userPassword)) {
                alert("Enter the Details");
            }
            else {
                if ((userName !="alpha") ||(userPassword !="beta")) {
                    alert('Enter correct username and password');
                }
                else {
                    //here i want to load my selectOption.html file ?
                }              
            }                                   
        });                           
    });
</script>

my code under <body> is

<body>
    <div data-role="page" id="home">         
        <div data-role="header">             
            <h1>Enter Credential</h1>                       
        </div>

        <div data-role="content">
            <label for="UserName">User Name</label>
            <input type="text" name="UserName" id="UserName" value="" style="width:220px;"  />

            <label for="Password">Password</label>
            <input type="password" name="Password" id="Password" value="" style="width:220px;"  />

            <div id="submitBtn" data-role="button">Submit</div>
        </div>  
    </div>
</body>

The function is getting called but how can I load the selectOption.html file?

Share Improve this question edited Jan 4, 2012 at 14:07 Rory McCrossan 338k41 gold badges320 silver badges351 bronze badges asked Jan 4, 2012 at 13:50 Ajeet Pratap MauryaAjeet Pratap Maurya 4,2643 gold badges30 silver badges46 bronze badges 1
  • When you say "load another file", do you mean "redirect to another file"? – CedX Commented Jan 4, 2012 at 14:01
Add a ment  | 

2 Answers 2

Reset to default 5

Have you tried using the jQuery Mobile method to perform navigation?

$.mobile.changePage("newpage.html");

http://jquerymobile./demos/1.0/docs/api/methods.html

I found the answer

to load any page you can simply do

$.mobile.changePage("yourHTML.html","slideup");

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745161173a4614396.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信