|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
help with client side refresh javascript
Hi guys,
I have a form set up using PHP, MYSQL, and HTML. Basically I am using radio buttons to give the user options of what product to select, then depending on the product they want to purchase I'm displaying my price at the bottom of the page, fairly simple. I am new to java but have heard that you can preload everything and make it user side to make refresh times almost non-existent. Up to now I have been unsuccessfull finding any sort of guides, sample codes, or similar topics on forums. If anyone has any advice, links, or knows of any books that tackle this problem please help. I basically just need some direction. Thanks. |
|
#2
|
|||
|
|||
|
RE: help with client side refresh javascript
Btw, its Javascript not Java, Java is an entirely different language.
Well I suppose you could just use an array in the Javascript that contains the relevant prices. Then using document.pricetextboxname.value = prices(num) But this will be better if you can use a server side language to put into the javascript array only the prices needed for the category that the user is in. |
|
#3
|
|||
|
|||
|
RE: help with client side refresh javascript
Yea, sorry, I meant javascript. I need a little more then that, are there in books out that talk about this, or any tutorials on the web that I'm missing. Thanks.
|
|
#4
|
|||
|
|||
|
RE: help with client side refresh javascript
Sorry I didn't mean to post anonymously, that last post was me though.
|
|
#5
|
|||
|
|||
|
RE: help with client side refresh javascript
I assume you are getting all the info of the products from the database and storing it in an multi array .ie. $array[item_id][item_info]
Therefore you can have a Javascript thing at the top of your page that the php can insert the prices into: <script> <?php echo "prices = new array("; for($i=0;$i<count($item_array);$i++){ echo $item_array[$i]["price"]."," } echo ")n"; ?> function add(id){ document.pricetextbox.value = document.pricetextbox.value + prices[id] } </script> Then your data: <?php for($i=0;$i<count($item_array);$i++){ echo $item_array[$i]["info"]; echo $item_array[$i]["price"]; echo "<input type="button" onClick="add(".$i.")" value="Add this item">n"; } echo "<br>n"; echo "<form method="post" action="buypage">n"; echo "Total: £<input type="text" name="pricetextbox" value="00.00">n"; echo "<input type="submit" name="submit" = value=" Submit ">n"; echo "</form>n"; ?> |
|
#6
|
|||
|
|||
|
RE: help with client side refresh javascript
Thanks guys! Works beautifully!
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > help with client side refresh javascript |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|