2014-01-23 114 views
4

我試圖在單頁中提交三個表單。但我堅持一點。 我想在第一個表格中對移動號碼進行驗證。然後使用該手機號碼在最後的表單提交來自html中單個頁面的多個web服務請求

我已經在單一的形式使用這種嘗試,但後來我如何發送Web請求發送的驗證碼與驗證移動按鈕。

我有三種形式這樣,

//First Form Take Mobile Number, web service will send verification Pin as reply to this action 
    <form name="PhoneVerification" action="url to phone verification web service" > 
    Phone Number: <input type="text" name ="number" id="phone"> 
    <input type="submit" name ="submit1" id="submit1">Verify Mibile Number</input> 
    </form> 

//Second Form verifies pin Locally which is sent by first service 
    <form name="PinVerification" action="verify pin came from previous web service"> 
    Verification Pin(Sent on Mobile Number): <input type="text" name ="pin" id="pin"> 
    <input type="submit" name ="submit2" id="submit2">Verify Pin</input> 
    </form> 

//Third Form Will Take Mobile Number Previously Entered. and email/password and Complete Signup 
    <form action="web service call to complete signup"> 
    Email: <input type="text" name ="email" id="email"> 
    Password: <input type="text" name ="pass" id="pass"> 
    PasswordAgain: <input type="text" name ="passAgain" id="passAgain"> 
    <input type="submit" name ="submit3" id="submit3">Complete Signup</input> 
    </form> 

的問題是我不能夠因爲頁面是表單提交後刷新獲得的電話號碼值。

我讀了一些關於使用AJAX的線程,但是我怎樣才能在這種情況下使用Ajax。 我該如何做到這一點。使用AJAX或使用PHP。

+0

使用本地存儲或會話。 –

+0

@CJRamki本地存儲您指的是在HTML或數據庫中的標記? –

+0

嘗試使用Cookie ... –

回答

1

您可以使用cookiessessions來完成此任務。

如果你只想用javascript來做,你可以使用cookies。你可以從w3schools

您就可以使用PHP和AJAX的使用服務器端腳本做最好的參考。 在這種情況下,您可以使用session

cookiessession首先表單提交門店數量。並以另一種形式從cookiesession中獲得該值並使用它。

注意:在完成所有工作後,請勿忘記刪除cookiessession

2
Id must be unique in your html page. In above code id="phone" be present in first to forms. the second form in pinVerfication right but there is an same id = "phone" . please change it and make an another try. third form have also same problem 

    //Second Form verifies pin Locally which is sent by first service 
     <form name="PinVerification" action="verify pin"> 
     Verification Pin(Sent on Mobile Number): <input type="text" name ="number" id="pin"> 
     <input type="submit" name ="submit2" id="submit2">Verify Pin</input> 
     </form> 

/Third Form Will Take Mobile Number Previously Entered. and email/password and Complete Signup 
    <form action="web service call to complete signup"> 
    Email: <input type="text" name ="email" id="email"> 
    Password: <input type="text" name ="pass" id="pass"> 
    PasswordAgain: <input type="text" name ="passAgain" id="passAgain"> 
    <input type="submit" name ="submit3" id="submit3">Complete Signup</input> 
    </form> 
相關問題